public IActionResult AddPesticide(NewPesticideVm model)
 {
     if (ModelState.IsValid)
     {
         _pesticideService.AddPesticide(model, userId);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
 public IActionResult EditPesticide(NewPesticideVm model)
 {
     if (ModelState.IsValid)
     {
         _pesticideService.UpdatePesticide(model);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
        public void AddPesticide(NewPesticideVm newPesticide, string userId)
        {
            var pesticide = _mapper.Map <Pesticide>(newPesticide);

            pesticide.TypeProductId = 3;
            pesticide.UserId        = userId;
            pesticide.CurrentAmount = pesticide.Capacity;

            _genericRepository.Add <Pesticide>(pesticide);
        }
        public IActionResult AddPesticide()
        {
            var warehouseSelectList     = _warehouseService.GetAllWarehouseForSelectList(userId);
            var typePesticideSelectList = _typePesticideService.GetAllTypePesticideForSelectList();

            var model = new NewPesticideVm()
            {
                TypePesticide = typePesticideSelectList,
                Warehouses    = warehouseSelectList
            };

            return(View(model));
        }
        public void UpdatePesticide(NewPesticideVm editPesticide)
        {
            var pesticide = _mapper.Map <Pesticide>(editPesticide);

            _pesticideRepository.UpdatePesticide(pesticide);
        }