public async Task <BaseResponse> BannerRemove(BannerRemoveRequest request)
        {
            BaseResponse response = new BaseResponse();

            try
            {
                var userLogin = await _context.GetCurrentCustomer();

                var command = request.ToCommandRemove(userLogin.Id);
                var result  = await _bannerService.SendCommand(command);

                if (result.IsSucess)
                {
                    response.SetSucess();
                }
                else
                {
                    response.SetFail(result.Message);
                }
            }
            catch (Exception e)
            {
                response.SetFail(e);
                _logger.LogError(e, e.Message, request);
            }
            return(response);
        }
Esempio n. 2
0
 public static BannerRemoveCommand ToCommandRemove(this BannerRemoveRequest command, string userId)
 {
     if (command == null)
     {
         return(null);
     }
     return(new BannerRemoveCommand()
     {
         Id = command.Id,
         UpdatedUid = userId
     });
 }
 public async Task <IActionResult> Remove([FromBody] BannerRemoveRequest request)
 {
     try
     {
         var response = new BaseResponse();
         ValidationResult validate = BannerRemoveRequestValidate.ValidateModel(request);
         if (validate.IsValid)
         {
             response = await _bannerAppService.BannerRemove(request);
         }
         else
         {
             response.SetFail(validate.Errors.Select(p => p.ToString()));
         }
         return(Json(response));
     }
     catch (Exception e)
     {
         _logger.LogError(e, Common.Common.GetMethodName(), request);
         throw;
     }
 }