ویژگی های قالب های نقاش: ریسپانسیو، مدرن، حرفه ای و استفاده از طراحی روز

مراحل تعریف کلاس در معماری جدید

1- ایجاد کلاس Test در Domain

 

using NNP.Infrastructure.Abstractions;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ~.Domain
{
    public class Test: ModelBase, IValidatableObject
    {

        //Field list
        // public int Field1 { get; set; }

        // public int Field2 { get; set; }


        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            List<ValidationResult> errors = new List<ValidationResult>();
            return errors;
        }
    }
    public class TestParam
    {       

       // public int Field1 { get; set; }
       // public int Field2 { get; set; }

       // ...

    }
}

2- ایجاد کلاس اینترفیس ITestRepository در  Repository.Contracts 

 

using ~.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NNP.Infrastructure.Abstractions;

namespace ~.Repository.Contracts
{
    public interface ITestRepository
    {
         
        Task<IEnumerable< Test>> List(TestParam model);
        //Task<Test> Info(ParamInfo Param);
        //Task<int> Update(Test model);
    }
}

 

3- ایجاد کلاس TestRepository در Repository.Implements

 

using ~.Domain;
using ~.Repository.Contracts;
using NNP.Infrastructure.Abstractions;
using NNP.Infrastructure.Abstractions.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ~.Repository.Implements
{
    public class TestRepository :ITestRepository
    {

        private readonly IDapperQueryExecution _QueryExecution;

        public TestRepository(IDapperQueryExecution queryExecution)
        {
            _QueryExecution = queryExecution;
        }
        public Task<IEnumerable<Test>> List(TestParam model)
        {
            return NNPCommon.ListQuery<Test, TestParam>(model, NNPConstant.RowCount, NNPConstant.noSerialOutPut, StoredProc.Test.sp_~TestList, _QueryExecution);
        }
        /*
        public Task<Test> Info(ParamInfo Param)
        {
            return NNPCommon.InfoQuery<Test, ParamInfo>(Param, NNPConstant.noRowCount, NNPConstant.noSerialOutPut, StoredProc.Test.sp_~TestInfo, _QueryExecution);
        }
        */
        /*
        public   Task<int> Update(Test model)
        {
            return NNPCommon.UpdateQuery<Test>(model, NNPConstant.noRowCount, NNPConstant.SerialOutPut, StoredProc.Test.sp_~TestUpdate, _QueryExecution);
        }
        */
    }
}

 

4- ایجاد کلاس Test در  Service.Model

 

using ~.Domain;
using NNP.Infrastructure.Abstractions;
using NNP.Infrastructure.Abstractions.Utilities;
using NNP.Infrastructure.Services.WebApi.Messages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ~.Service.Models
{
    public class TestRequest
    {

        public Test Data { get; set; }
        // public ContactList ListParam { get; set; }
        //    public ContactList ListParam { get; set; }

        public TestList ListParam { get; set; }

        public ParamInfo InfoParam { get; set; }

        public TestParam ConvertParam()
        {
            return NNPCommon.AutoMap<Service.Models.TestList, Domain.TestParam>(ListParam);

        }

    }

    public class TestList : ParamBase  //برای ورودی لیست و جستجو
    {
       // public long Field1 { get; set; }
       // public int Field2 { get; set; }

    }

    public class TestResponse : ResponseBase<Test>  // برای خروجی
    {

        public IEnumerable<Test> List { get; set; }
        public Test Data { get; set; }

    }
}

 

5- ایجاد کلاس اینترفیس ITestService در Service.Contracts

 

using ~.Service.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ~.Service.Contracts
{
    public interface ITestService
    {

        Task<TestResponse> List(TestRequest model);
        //Task<TestResponse> Info(TestRequest model);
        //Task<TestResponse> Update(TestRequest model);
    }
}

 

6- ایجاد کلاس TestService در Service.Implements

 

using ~.Service.Contracts;
using ~.Service.Models;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace ~.WepApi.Controllers
{

    [EnableCors]
    [Route("api/ExpTest")]
    [ApiController]
    public class TestController : ControllerBase
    {

        ITestService _TestService;
        public TestController(ITestService TestService)
        {
            _TestService = TestService;
        }

         
        [Route("list")]
        [HttpPost]
        public async Task<IActionResult> list(TestRequest Request)
        {
            return Ok(await _TestService.List(Request));
        }
        
        /*
        [Route("info")]
        [HttpPost]
        public async Task<IActionResult> Info(TestRequest Request)
        {
            return Ok(await _TestService.Info(Request));
        }

        */

        /*
        public async Task<TestResponse> Update(TestRequest model)
        {
            var userId = new ApplicationUser(HttpContext.Current.User).Id;
            model.Data.PersonnelRef = NNPUtility.MakeInt(userId.ToString());

            int Serial = await _Repository.Update(model.Data);

            if (model.Data.SpMode == "INS")
            {
                var uploadModel = new UploadDTO()
                {
                    TableXRef = Serial,
                    ListUpload = model.ListUpload,
                };
                var status = await _ApiService.CallApiUploadTableXref(uploadModel);
                if (status.IsSuccess == false)
                {
                    return new TestResponse()
                    {
                        Serial = Serial,
                        Message = new UnSuccessfullSaveResponseMessage(ResponseMessageTexts.UNSUCCESSFULLUpload_SAVE, ResponseMessagePriority.Low),
                    };

                }

            }

            return new TestResponse()
            {
                Serial = Serial,
                Message = new SuccessfullGetResponseMessage(ResponseMessageTexts.SUCCESSFULL_SAVE, ResponseMessagePriority.Low),
            };
        }
        */
    }
}

 

7- ایجاد کلاس کنترلر TestController در WepApi.Controllers

 

using ~.Service.Contracts;
using ~.Service.Models;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace ~.WepApi.Controllers
{

    [EnableCors]
    [Route("api/ExpTest")]
    [ApiController]
    public class TestController : ControllerBase
    {

        ITestService _TestService;
        public TestController(ITestService TestService)
        {
            _TestService = TestService;
        }

         
        [Route("list")]
        [HttpPost]
        public async Task<IActionResult> list(TestRequest Request)
        {
            return Ok(await _TestService.List(Request));
        }
        
        /*
        [Route("info")]
        [HttpPost]
        public async Task<IActionResult> Info(TestRequest Request)
        {
            return Ok(await _TestService.Info(Request));
        }

        [Route("insert")]
        [HttpPost]
        public async Task<IActionResult> insert(TestRequest Request)
        {

            return Ok(await _TestService.Update(Request));

        }

        [Route("update")]
        [HttpPost]
        public async Task<IActionResult> Update(TestRequest Request)
        {
            return Ok(await _TestService.Update(Request));
        }

        [Route("delete")]
        [HttpPost]
        public async Task<IActionResult> Delete(TestRequest Request)
        {
            return Ok(await _TestService.Update(Request));
        }

        */
    }
}

 

نمايش: ۲۳۵