public ActionResult ServiceCreation(CustomerOfferViewModel customerOffer) { customerOffer.Time = DateTime.Now; customerOffer.UserId = User.Identity.GetUserId(); var mapper = new MapperConfiguration(cfg => cfg.CreateMap <CustomerOfferViewModel, CustomerOfferDTO>()).CreateMapper(); var customerOfferDTO = mapper.Map <CustomerOfferViewModel, CustomerOfferDTO>(customerOffer); serviceCustomerOffer.Create(customerOfferDTO); return(RedirectToAction(actionName: "ListOfCompanies", routeValues: new { offerId = customerOffer.OfferId })); }
public ActionResult MakeCustomerOffer(CustomerOfferViewModel model) { try { var customerOfferDto = new CustomerOfferDTO { CustomerID = 1, Order = model.Order, Price = model.Price, TimeRealization = model.TimeRealization }; customerOfferService.MakeCustomerOffer(customerOfferDto); return(Content("<h2>Your order is successfully completed</h2>")); } catch (ValidationException ex) { ModelState.AddModelError("", ex.Message); } return(View(model)); }
public ActionResult MakeCustomerOffer(int?id) { try { CustomerDTO customer = customerService.GetCustomer(id); var order = new CustomerOfferViewModel { CustomerID = customer.Id }; return(View(order)); } catch (ValidationException ex) { return(Content(ex.Message)); } }