public async Task <ActionResult> AddCar([Bind(Include = "id,IdClientsGroups,IdMark,IdModel,IdBody,IdInfoClient,NumberCar,discont,note")] ClientsOfCarWashView clientsOfCarWashView)
        {
            if (TempData.ContainsKey("Mark") == true && TempData.ContainsKey("Model") == true)
            {
                clientsOfCarWashView.IdMark  = Int32.Parse(TempData["Mark"].ToString());
                clientsOfCarWashView.IdModel = Int32.Parse(TempData["Model"].ToString());

                var itemList = TempData["IdClient"] as List <int>;

                clientsOfCarWashView.IdInfoClient    = itemList[0];
                clientsOfCarWashView.IdClientsGroups = itemList[1];
                clientsOfCarWashView.arxiv           = true;

                if (ModelState.IsValid)
                {
                    ClientsOfCarWashBll clients = Mapper.Map <ClientsOfCarWashView, ClientsOfCarWashBll>(clientsOfCarWashView);
                    await _services.Insert(clients);

                    return(RedirectToAction("Client"));
                }
            }

            ViewBag.Body  = new SelectList(await _carBody.GetTableAll(), "Id", "Name");
            ViewBag.Group = new SelectList(await _clientsGroups.GetClientsGroups(), "Id", "Name");

            return(View(clientsOfCarWashView));
        }
        public async Task <ActionResult> EditCarClient([Bind(Include = "id,IdClientsGroups,IdMark,IdModel,IdBody,IdInfoClient,NumberCar,discont,note")] ClientsOfCarWashView clientsOfCarWashView, int idCar)
        {
            if (ModelState.IsValid)
            {
                ClientsOfCarWashView clientsOfCarWash = Mapper.Map <ClientsOfCarWashView>(await _services.GetId(idCar));

                clientsOfCarWashView.id              = clientsOfCarWash.id;
                clientsOfCarWashView.IdInfoClient    = clientsOfCarWash.IdInfoClient;
                clientsOfCarWashView.IdMark          = clientsOfCarWash.IdMark;
                clientsOfCarWashView.IdModel         = clientsOfCarWash.IdModel;
                clientsOfCarWashView.IdClientsGroups = clientsOfCarWash.IdClientsGroups;
                clientsOfCarWashView.arxiv           = clientsOfCarWash.arxiv;

                ClientsOfCarWashBll clients = Mapper.Map <ClientsOfCarWashView, ClientsOfCarWashBll>(clientsOfCarWashView);
                await _services.ClientCarUpdate(clients);

                return(RedirectToAction("Info", "ClientsOfCarWashViews", new RouteValueDictionary(new
                {
                    idClientInfo = clientsOfCarWash.IdInfoClient,
                    idClient = clientsOfCarWash.id
                })));
            }

            ViewBag.Body  = new SelectList(await _carBody.GetTableAll(), "Id", "Name");
            ViewBag.Group = new SelectList(await _clientsGroups.GetClientsGroups(), "Id", "Name");

            return(View(clientsOfCarWashView));
        }
        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));
        }
Пример #4
0
        public async Task <int> Insert(ClientsOfCarWashBll AddCliens)
        {
            ClientsOfCarWash clientsOfCarWash = TransformAnEntity(AddCliens);

            _unitOfWork.ClientsOfCarWashUnitOfWork.Insert(clientsOfCarWash);

            await _unitOfWork.Save();

            return(clientsOfCarWash.id);
        }
Пример #5
0
        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);
        }
Пример #6
0
 private ClientsOfCarWash TransformAnEntity(ClientsOfCarWashBll entity) =>
 Mapper.Map <ClientsOfCarWashBll, ClientsOfCarWash>(entity);
Пример #7
0
        public async Task ClientCarUpdate(ClientsOfCarWashBll updateClientCar)
        {
            _unitOfWork.ClientsOfCarWashUnitOfWork.Update(TransformAnEntity(updateClientCar));

            await _unitOfWork.Save();
        }
Пример #8
0
 public async Task Delete(ClientsOfCarWashBll elementToDelete)
 {
     _unitOfWork.ClientsOfCarWashUnitOfWork.Delete(elementToDelete.id);
     await _unitOfWork.Save();
 }