public async Task <UpdateCustomerRes> UpdateCustomer(UpdateCustomerReq request)
        {
            DynamicParameters parameters = new DynamicParameters();

            parameters.Add(name: "@CustomerId", request.CustomerId);
            parameters.Add(name: "@FirstName", request.FirstName);
            parameters.Add(name: "@LastName", request.LastName);
            parameters.Add(name: "@DateOfBirth", request.DateOfBirth);
            parameters.Add(name: "@Address", request.Address);
            parameters.Add(name: "@PhoneNumber", request.PhoneNumber);
            parameters.Add(name: "@IdentityNumber", request.IdentityNumber);
            parameters.Add(name: "@Email", request.Email);
            parameters.Add(name: "@Gender", request.Gender);
            parameters.Add(name: "@DateOfIssuanceIdentityNumber", request.DateOfIssuanceIdentityNumber);
            parameters.Add(name: "@PlaceOfIssuanceIdentityNumber", request.PlaceOfIssuanceIdentityNumber);
            parameters.Add(name: "@Message", "", DbType.String, ParameterDirection.Output);
            using (var result = SqlMapper.QueryFirstOrDefaultAsync <Customer>(
                       cnn: connection,
                       sql: "sp_UpdateCustomer",
                       param: parameters,
                       commandType: CommandType.StoredProcedure))
            {
                try
                {
                    UpdateCustomerRes editRes = new UpdateCustomerRes();
                    editRes.Customer = await result;
                    editRes.Message  = parameters.Get <string>("@Message");
                    return(editRes);
                }
                catch (Exception)
                {
                    return(new UpdateCustomerRes());
                }
            }
        }
Пример #2
0
        public async Task <IActionResult> Update([FromRoute] Guid code, [FromBody] UpdateCustomerReq req)
        {
            var merchantCode = Guid.Parse(User.Claims.FirstOrDefault(x => x.Type == "MerchantCode").Value);
            var merchantName = User.Claims.FirstOrDefault(x => x.Type == "MerchantName").Value;
            var response     = await _mediator.Send(new UpdateCustomerCommand(merchantCode, code, req.Email, req.Phone, req.FirstName, req.LastName, merchantName, req.Addresses));

            if (response != null)
            {
                return(Accepted(response));
            }
            else
            {
                return(Conflict());
            }
        }
 public async Task <IActionResult> UpdateCustomer(UpdateCustomerReq request)
 {
     return(Ok(await _customerServices.UpdateCustomer(request)));
 }
 public async Task <UpdateCustomerRes> UpdateCustomer(UpdateCustomerReq request)
 {
     return(await _customerRepository.UpdateCustomer(request));
 }