예제 #1
0
        public OperationResponse <CustomerThirdPartyAppSettingInsertCommandOutputDTO> Insert(CustomerThirdPartyAppSettingInsertCommandInputDTO input)
        {
            var result = new OperationResponse <CustomerThirdPartyAppSettingInsertCommandOutputDTO>();
            var entity = new CustomerThirdPartyAppSetting
            {
                CustomerId           = input.CustomerId,
                ThirdPartyAppTypeId  = input.ThirdPartyAppTypeId,
                ThirdPartyCustomerId = input.ThirdPartyCustomerId,
            };

            var dbLocator = AmbientDbContextLocator.Get <RiverdaleDBContext>();
            {
                dbLocator.Add(entity);
                dbLocator.SaveChanges();

                var dbResult = dbLocator.Set <CustomerThirdPartyAppSetting>().Where(o => o.Id == entity.Id).Select(o => new CustomerThirdPartyAppSettingInsertCommandOutputDTO
                {
                    Id                   = o.Id,
                    CustomerId           = o.CustomerId,
                    CustomerName         = o.Customer.Name,
                    ThirdPartyAppTypeId  = o.ThirdPartyAppTypeId,
                    ThirdPartyCustomerId = o.ThirdPartyCustomerId,
                }).FirstOrDefault();

                result.Bag = dbResult;

                return(result);
            }
        }
예제 #2
0
        public IActionResult Post([FromBody] CustomerThirdPartyAppSettingInsertCommandInputDTO model)
        {
            var appResult = this.InsertCommand.Execute(model);

            return(appResult.IsSucceed ? (IActionResult)this.Ok(appResult) : (IActionResult)this.BadRequest(appResult));
        }
 public OperationResponse <CustomerThirdPartyAppSettingInsertCommandOutputDTO> Execute(CustomerThirdPartyAppSettingInsertCommandInputDTO input)
 {
     using (var dbContextScope = this.DbContextScopeFactory.Create())
     {
         return(this.Repository.Insert(input));
     }
 }