public async Task <int> Distribute(ClientViewsBll client) { ClientsOfCarWashBll clientsOfCarWash = new ClientsOfCarWashBll(); ClientInfoBll clientInfoBll = new ClientInfoBll(); clientInfoBll.Name = client.Name; clientInfoBll.Surname = client.Surname; clientInfoBll.PatronymicName = client.PatronymicName; clientInfoBll.Phone = client.phone; clientInfoBll.DateRegistration = client.DateRegistration; clientInfoBll.Email = client.Email; clientInfoBll.barcode = client.barcode; clientInfoBll.note = client.note; ClientInfo clientInfo = Mapper.Map <ClientInfoBll, ClientInfo>(clientInfoBll); _unitOfWork.ClientInfoUnitOfWork.Insert(clientInfo); await _unitOfWork.Save(); clientsOfCarWash.IdBody = client.IdBody; clientsOfCarWash.IdClientsGroups = client.IdClientsGroups; clientsOfCarWash.IdInfoClient = clientInfo.Id; clientsOfCarWash.IdMark = client.Idmark; clientsOfCarWash.IdModel = client.Idmodel; clientsOfCarWash.IdBody = client.IdBody; clientsOfCarWash.NumberCar = client.NumberCar; clientsOfCarWash.discont = client.discont; clientsOfCarWash.arxiv = true; ClientsOfCarWash clientsOfCar = Mapper.Map <ClientsOfCarWashBll, ClientsOfCarWash>(clientsOfCarWash); _unitOfWork.ClientsOfCarWashUnitOfWork.Insert(clientsOfCar); await _unitOfWork.Save(); return(clientsOfCar.id); }
public async Task <ActionResult> NewClient([Bind(Include = "Id,Surname,Name,PatronymicName,phone,DateRegistration,Email,discont,Recommendation,NumberCar,IdClientsGroups,IdBody,note,barcode")] ClientView clientView, bool Page, int?Service) { if (TempData.ContainsKey("Mark") && TempData.ContainsKey("Model") && clientView.IdBody != null) { clientView.Idmark = Int32.Parse(TempData["Mark"].ToString()); clientView.Idmodel = Int32.Parse(TempData["Model"].ToString()); clientView.DateRegistration = DateTime.Now; if (ModelState.IsValid) { if ((TempData.ContainsKey("Checkout"))) { string typeService = TempData["Checkout"].ToString(); TempData.Keep("Checkout"); if (Service != null) { ClientViewsBll client = Mapper.Map <ClientView, ClientViewsBll>(clientView); int idNewClient = await _clientModules.Distribute(client); var carBody = Mapper.Map <CarBodyView>(await _carBody.SelectId(Convert.ToInt32(clientView.IdBody))); return(RedirectToAction("NewOrder", "ClientsOfCarWashViews", new RouteValueDictionary(new { id = idNewClient, body = carBody.Name, Services = Service }))); } else { return(RedirectToAction("NewClient", "Client", new RouteValueDictionary(new { idPage = typeService }))); } } else { if (Page) { ClientViewsBll client = Mapper.Map <ClientView, ClientViewsBll>(clientView); int idNewClient = await _clientModules.Distribute(client); var carBody = Mapper.Map <CarBodyView>(await _carBody.SelectId(Convert.ToInt32(clientView.IdBody))); return(RedirectToAction("../ClientsOfCarWashViews/Client")); } else { return(RedirectToAction("../Client/NewOrder")); } } } } if (Service == 3) { ClientViewsBll client = Mapper.Map <ClientView, ClientViewsBll>(clientView); int idNewClient = await _clientModules.Distribute(client); return(RedirectToAction("CreateOrder", "TireChangeService", new RouteValueDictionary(new { IdClient = idNewClient }))); } ViewBag.Body = new SelectList(await _carBody.GetTableAll(), "Id", "Name"); ViewBag.Group = new SelectList(await _clientsGroups.GetClientsGroups(), "Id", "Name"); if ((TempData.ContainsKey("Checkout"))) { string typeService = TempData["Checkout"].ToString(); return(RedirectToAction("NewClient", "Client", new RouteValueDictionary(new { idPage = typeService }))); } else { return(View()); } }