public async Task <ActionResult> EditClient([Bind(Include = "id,Surname,Name,PatronymicName,Phone,DateRegistration,Email,barcode,note")] ClientInfoView client, int IdClient, int idCar, int?SelectGroupClient)
        {
            if (ModelState.IsValid)
            {
                ClientInfoView clientInfo = Mapper.Map <ClientInfoView>(await _clientInfo.ClientInfoGetId(IdClient));
                clientInfo = client;

                ClientInfoBll clientInfoBll        = Mapper.Map <ClientInfoView, ClientInfoBll>(client);
                var           clientsOfCarWashView = Mapper.Map <IEnumerable <ClientsOfCarWashView> >(await _services.GetAll(idCar));

                foreach (var item in clientsOfCarWashView)
                {
                    item.IdClientsGroups = SelectGroupClient;

                    ClientsOfCarWashBll clients = Mapper.Map <ClientsOfCarWashView, ClientsOfCarWashBll>(item);
                    await _services.ClientCarUpdate(clients);
                }
                await _clientInfo.Update(clientInfoBll);

                return(RedirectToAction("Info", "ClientsOfCarWashViews", new RouteValueDictionary(new
                {
                    idClientInfo = idCar,
                    idClient = IdClient
                })));
            }

            ViewBag.Group = new SelectList(await _clientsGroups.GetClientsGroups(), "Id", "Name");
            return(View(client));
        }
Example #2
0
        public async Task <ActionResult> EditClient([Bind(Include = "id,Surname,Name,PatronymicName,Phone,DateRegistration,Email,barcode,note")] ClientInfoView client, int idClient)
        {
            if (ModelState.IsValid)
            {
                ClientInfoView clientInfo = Mapper.Map <ClientInfoView>(await _clientInfo.ClientInfoGetId(idClient));
                clientInfo = client;

                ClientInfoBll clientInfoBll = Mapper.Map <ClientInfoView, ClientInfoBll>(client);

                await _clientInfo.Update(clientInfoBll);

                return(RedirectToAction("ClientDetails", "ClientInfo", new RouteValueDictionary(new
                {
                    id = idClient
                })));
            }

            return(View(client));
        }