public IActionResult AddMachineToOrder(AddMachintPostDTO dto)
        {
            var result = orderManager.AddNewMachineryOnShift(dto);

            dbManager.Commit();
            string message = result ? $"Объект сохранён" : "Не удалось";
            var    res     = new ResultViewModel(message, message, $"/order?orderIdforce={dto.OrderId}", "Назад");

            return(View("Result", res));
        }
Ejemplo n.º 2
0
        public bool AddNewMachineryOnShift(AddMachintPostDTO dto)
        {
            bool result;
            var  Area    = dbManager.GetById <QuarryArea>(dto.AreaId);
            var  Field   = dbManager.GetById <QuarryField>(dto.FieldId);
            var  Horizon = dbManager.GetById <QuarryHorizon>(dto.HorizonId);
            var  Group   = dbManager.GetById <Group>(dto.GroupId);
            var  Plast   = dbManager.GetById <QuarryPlast>(dto.PlastId);
            var  Crew    = dto.Crew != null?dbManager.GetByListId <Employee>(dto?.Crew) : null;

            bool             PZO     = dto.PZO == "on";
            bool             HighAsh = dto.HighAsh == "on";
            var              order   = dbManager.GetById <Order>(dto.OrderId);
            MachineryOnShift obj;

            if (dto.MoSId > 0)
            {
                obj    = dbManager.GetById <MachineryOnShift>(dto.MoSId);
                result = true;
            }
            else
            {
                var mach = dbManager.GetById <Machinery>(dto.MachineId);
                obj = new MachineryOnShift(mach);
                order.AddMachines(obj);
                obj.SetOrder(order);
                result = dbManager.AddAsync(obj);
            }
            dto.ConvertToDouble();
            obj.SetLocation(Area, Field, Horizon, Plast, dto.Picket)
            .SetGroup(Group, dto.Number)
            .SetOrderProperties(dto.Weight, dto.Volume, dto.Overex, dto.Ash, dto.Heat, dto.Wet, HighAsh)
            .SetDownTime(dto.Transport, dto.Repair, dto.HoliDays)
            .SetCrew(Crew)
            .SetPZO(PZO);
            return(result);
        }