Exemple #1
0
        public async Task AddNewAsync(StoreHouseViewModel model)
        {
            var sHouse = _mapper.Map <StoreHouse>(model);
            await _context.AddAsync(sHouse);

            await _context.SaveChangesAsync();
        }
        public IActionResult Create()
        {
            var viewModel = new StoreHouseViewModel
            {
                TypeList     = new SelectList(_medicalBillsTypeService.GetAll().ToList()),
                FormList     = new SelectList(_formService.GetAll().ToList()),
                MedicalBills = new SelectList(_medicalBillsService.GetAll())
            };

            return(View(viewModel));
        }
        public IActionResult Delete(int id)
        {
            StoreHouseDTO       store          = _storeHouseServices.GetAll().FirstOrDefault(u => u.Id == id);
            StoreHouseViewModel modelViewModel = new StoreHouseViewModel
            {
                Id       = store.Id,
                Name     = store.MedicalBills.Name,
                Type     = store.MedicalBills.MedicalBillsType.Type,
                Form     = store.MedicalBills.Form.FormName,
                Quantity = 1
            };

            return(View(modelViewModel));
        }
 public IActionResult Create(StoreHouseViewModel storeHouse)
 {
     if (ModelState.IsValid)
     {
         var store = new StoreHouseDTO
         {
             DateOfManufacture = storeHouse.DateOfManufacture,
             ShelfLife         = storeHouse.ShelfLife,
             MedicalBills      = _medicalBillsService.GetAll().FirstOrDefault(u => u.Name == storeHouse.Name)
         };
         _storeHouseServices.Add(store);
         return(RedirectToAction("List"));
     }
     return(View());
 }
Exemple #5
0
        public async Task UpdateStoreHouseByIdAsync(StoreHouseViewModel model)
        {
            var sHouse = await _context.StoreHouse.Where(s => s.Id == model.Id).SingleOrDefaultAsync();

            if (sHouse != null)
            {
                sHouse.FirstInventory         = model.FirstInventory;
                sHouse.ComapnyId              = model.ComapnyId;
                sHouse.InventoryEndDateTime   = (model.InventoryEndDateTime.Trim() != string.Empty ? (DateTime)model.InventoryEndDateTime.ToMiladi() : null);
                sHouse.InventoryStartDateTime = (DateTime)model.InventoryStartDateTime.ToMiladi();
                sHouse.ProductId              = model.ProductId;
                sHouse.Status = model.Status;
                sHouse.UnitId = model.UnitId;
                await _context.SaveChangesAsync();
            }
        }
 public IActionResult Delete(StoreHouseViewModel storeHouseViewModel)
 {
     try
     {
         List <StoreHouseDTO> store = _storeHouseServices.GetAll().ToList();
         for (int i = 0; i < storeHouseViewModel.Quantity; i++)
         {
             //     _storeHouseServices.Remove(store[i]);
             _writeOfListService.Add(ConvertTo(store[i]));
         }
         return(RedirectToAction("List"));
     }
     catch
     {
         return(View());
     }
 }
        public IActionResult List()
        {
            List <StoreHouseViewModel> storeViewModel = new List <StoreHouseViewModel>();
            var store = _storeHouseServices.GetAll();

            foreach (StoreHouseDTO un in store)
            {
                if (!storeViewModel.Select(u => u.Name).Contains(un.MedicalBills.Name))
                {
                    StoreHouseViewModel model = new StoreHouseViewModel
                    {
                        Id       = un.Id,
                        Name     = un.MedicalBills.Name,
                        Type     = un.MedicalBills.MedicalBillsType.Type,
                        Form     = un.MedicalBills.Form.FormName,
                        Quantity = store.Where(u => u.MedicalBills.Id == un.MedicalBills.Id).Count()
                    };
                    storeViewModel.Add(model);
                }
            }

            return(View(storeViewModel));
        }
        public async Task <IActionResult> Post(StoreHouseViewModel model)
        {
            await _storeHouseServices.AddNewAsync(model);

            return(Ok());
        }
        public async Task <IActionResult> Put(StoreHouseViewModel model)
        {
            await _storeHouseServices.UpdateStoreHouseByIdAsync(model);

            return(Ok());
        }