private IEnumerable <ProductionShiftUseModel> AddMissingShifts(List <ProductionShiftUseDto> shifts, int lineId) { List <ProductionShiftUseModel> additionalShifts = new List <ProductionShiftUseModel>(); using (ProductionShiftService service = new ProductionShiftService()) { var dtos = service.GetAllByPlantId(CurrentPlantId); foreach (var dto in dtos) { if (shifts.FirstOrDefault(s => s.ShiftID == dto.ID) != null) { continue; } ProductionShiftUseModel additionalShift = new ProductionShiftUseModel() { PlantId = CurrentPlantId, LineID = lineId, Day1Minutes = 0, Day2Minutes = 0, Day3Minutes = 0, Day4Minutes = 0, Day5Minutes = 0, Day6Minutes = 0, Day7Minutes = 0, ShiftCode = dto.Code, ShiftID = dto.ID }; additionalShifts.Add(additionalShift); } } return(additionalShifts); }
public JsonResult FetchGridInfo(int productionLineId, DateTime week) { List <ProductionLineScheduleWeekly> items = new List <ProductionLineScheduleWeekly>(); List <ProductionLineScheduleDto> entities; List <ProductionShiftDto> shifts; using (ProductionShiftService service = new ProductionShiftService()) shifts = service.GetAllByPlantId(CurrentPlantId); foreach (ProductionShiftDto shift in shifts) { using (ProductionLineScheduleService service = new ProductionLineScheduleService()) entities = service.GetWeekly(CurrentPlantId, shift.ID, productionLineId, GetFirstDayOfWeek(week)); if (entities.Count == 0) { items.Add(CreateWeeklyInfo(shift)); } else { items.Add(PopulateWeeklyInfo(shift, entities)); } } return(Json(items, JsonRequestBehavior.AllowGet)); }
public JsonResult GetAllProductionShifts() { List <ProductionShiftModel> productionShifts = new List <ProductionShiftModel>(); using (ProductionShiftService svc = new ProductionShiftService()) { var dtos = svc.GetAllByPlantId(CurrentPlantId); productionShifts.AddRange(Mapper.Map <List <ProductionShiftDto>, List <ProductionShiftModel> >(dtos)); } return(Json(productionShifts, JsonRequestBehavior.AllowGet)); }