public ActionResult GetIsolatorOfflineDetail(int id) { var iso = isolatorService.GetIsolatorById(id); var shifts = lookupService.GetAllStandaredShifts(); var shiftIds = new String[0]; if (!string.IsNullOrEmpty(iso.OfflineShifts)) { shiftIds = iso.OfflineShifts.Split('|'); } var model = new IsolatorOfflineViewModel { IsolatorId = iso.IsolatorId, IsolatorName = iso.Abbriviation, StartDate = iso.OfflineStartDate, EndDate = iso.OfflineEndDate, AllShifts = shiftIds.Length == 0, ShiftList = new MultiSelectList(shifts.Select(p => new SelectListItem { Value = p.ShiftId.ToString(), Text = p.ShiftTitle }), "Value", "Text", shiftIds), }; return(PartialView("_IsolatorOffline", model)); }
public IActionResult SaveIsolatorOfflineDetail(IsolatorOfflineViewModel model) { if (!ModelState.IsValid) { return(Json(false)); } var response = isolatorService.SaveIsolatorOfflineDetail(model, CurrentUserName); return(Json(response)); }
public int SaveIsolatorOfflineDetail(IsolatorOfflineViewModel model, string user) { var iso = repository.GetContext().Isolators .Include(p => p.StaffShiftAllocations) .Include(p => p.PreperationOrders).ThenInclude(p => p.IntegrationOrder) .FirstOrDefault(p => p.IsolatorId == model.IsolatorId); if (iso == null || !model.StartDate.HasValue || !model.EndDate.HasValue) { return(0); } iso.OfflineStartDate = model.StartDate; iso.OfflineEndDate = model.EndDate; iso.OfflineShifts = model.AllShifts? null : string.Join("|", model.SelectedShifts); iso.SetUpdateDetails(user); //repository.SaveExisting(iso); //unmapping staff allocation foreach (var staffAllocation in iso.StaffShiftAllocations.Where(s => s.AllocatedDate.Date <= model.StartDate.Value.Date && s.AllocatedDate.Date <= model.EndDate.Value.Date && (!model.SelectedShifts.Any() || model.SelectedShifts.Contains(s.IsolatorShiftId)))) { staffAllocation.SetArchiveDetails(user); } //unmapping order scheduling foreach (var prepOrder in iso.PreperationOrders.Where(s => s.PreperationDateTime.Date <= model.StartDate.Value.Date && s.PreperationDateTime.Date <= model.EndDate.Value.Date && (!model.SelectedShifts.Any() || model.SelectedShifts.Contains(s.IsolatorStaffAllocation.IsolatorShiftId)))) { prepOrder.SetArchiveDetails(user); prepOrder.IntegrationOrder.OrderLastProgressId = (int)OrderProgressEnum.Scheduled; } repository.SaveChanges(); return(iso.IsolatorId); }