コード例 #1
0
 public IHttpActionResult WorkingHour(List <WorkingHourViewModel> workingHours)
 {
     try
     {
         var    identity  = (ClaimsIdentity)User.Identity;
         string accountId = identity.Claims.FirstOrDefault(c => c.Type.Equals("AccountId")).Value;
         _workingHourService.Update(accountId, workingHours);
         _slotService.GenerateSlotForSalon(accountId);
         return(Json("Update Working Hour Success"));
     }
     catch (Exception ex)
     {
         ErrorSignal.FromCurrentContext().Raise(ex);
         return(BadRequest("Update Profile Failed"));
     }
 }
コード例 #2
0
        public IHttpActionResult Update([FromBody] UpdateWorkingHourDto workingHour)
        {
            if (workingHour == null)
            {
                return(BadRequest());
            }
            //custom validations
            var validator = new UpdateWorkingHourDtoValidator();
            var results   = validator.Validate(workingHour);

            if (!results.IsValid)
            {
                foreach (var failure in results.Errors)
                {
                    ModelState.AddModelError(failure.PropertyName, failure.ErrorMessage);
                }
            }
            if (!ModelState.IsValid)
            {
                string errorMessage = new ModelStateError(_logger).OutputMessage(ModelState);
                return(BadRequest(errorMessage));
            }
            try
            {
                var result = _workingHourService.Update(workingHour);
                if (!result.IsValid)
                {
                    return(BadRequest(result.Message));
                }
                return(Ok());
            }
            catch (LogicalException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch
            {
                return(BadRequest(AppSettings.INTERNAL_SERVER_ERROR_MESSAGE));
            }
        }