public ActionResult MakeOrder(OrderViewModel order)
        {
            DepotDTO depot = depots.GetById(order.DepotId);

            if (depots.GetById(order.DepotId) == null)
            {
                return(RedirectToAction("MakeOrder"));
            }

            IEnumerable <DrugUnitDTO> unitsToSend = new List <DrugUnitDTO>();

            order.Lines.ForEach(line =>
            {
                if (line.Amount > 0)
                {
                    unitsToSend = unitsToSend.Concat(drugUnits.Purchase(order.DepotId, line.DrugTypeId, line.Amount));
                }
            });

            return(View("OrderSummary", new OrderSummaryViewModel()
            {
                Depot = depot,
                UnitsToSend = unitsToSend
            }));
        }
Example #2
0
        public void UpdateDrugUnitWithDepot(List <DrugUnitDepotUpdateServiceModel> updateModels)
        {
            foreach (var v in updateModels)
            {
                //fields:
                //  v.DepotID;
                //  v.DrugUnitPickNumber;
                /* злостный костыль */
                if (v.DepotID == null)
                {
                    continue;
                }

                var  drugUnit = _drugUnitService.GetByPickNumber(v.DrugUnitPickNumber);
                var  depot    = _depotService.GetById(v.DepotID);
                bool contains = depot.DrugUnits.Contains(drugUnit);
                if (!contains)
                {
                    depot.DrugUnits.Add(drugUnit);
                }
            }
        }