public OperationDetails Create(ResponseViewModelBLL response) { Mapper.Initialize(cfg => cfg.CreateMap <ResponseViewModelBLL, Response>() .ForMember("UserId", opt => opt.MapFrom(c => c.PerformerId))); _responseRepository.Create(Mapper.Map <ResponseViewModelBLL, Response>(response)); return(new OperationDetails(true, "Sending response succeeded", string.Empty)); }
public ActionResult Send(CreateResponseViewModel response) { bool responseIsEmpty = response.Text == null || response.Text.Equals(string.Empty); Mapper.Initialize(cfg => cfg.CreateMap <CreateResponseViewModel, ResponseViewModelBLL>() .ForMember("Date", opt => opt.MapFrom(c => DateTime.Now)) .ForMember("PerformerId", opt => opt.MapFrom(c => User.Identity.GetUserId <int>()))); ResponseViewModelBLL responseDto = Mapper.Map <CreateResponseViewModel, ResponseViewModelBLL>(response); if (ModelState.IsValid) { OperationDetails operationDetails = _responseService.Create(responseDto); _unitOfWork.Save(); if (!operationDetails.Succedeed) { ModelState.AddModelError(operationDetails.Property, operationDetails.Message); } } return(RedirectToAction("Details", "Orders", new { id = response.OrderId, emptyResponse = responseIsEmpty })); }