public ActionResult Edit(AddShiftVM shift) { try { var startAt = DateTime.Parse(shift.ShiftStartAt); var endAt = DateTime.Parse(shift.ShiftEndAt); bool isEdited = shiftServices.EditShift(new Shift() { ShiftId = shift.ShiftId, EmployeeId = shift.AssignedShiftEmployeeId, // Work around to fix bug UI cannot parse datetime. // Then simple get the DateOfShift plus the start/end hour of the shift StartTime = ((DateTime)shift.DateOfShift).AddHours(startAt.Hour), EndTime = ((DateTime)shift.DateOfShift).AddHours(endAt.Hour) }); if (!shift.IsCalendarView) { return(Json(new BaseViewModel <bool>(true, string.Empty, isEdited), JsonRequestBehavior.AllowGet)); } string dateOfShift = ((DateTime)shift.DateOfShift).ToString("MM-dd-yyyy"); string url = string.Format("ListShiftCalendarView?date={0}", dateOfShift); return(Redirect(url)); } catch (Exception ex) { return(Json(new BaseViewModel <bool>(true, ex.Message, false), JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(string shiftId, bool isCalendarView) { try { var lstEmployee = employeeServices.GetAllEmployeeOrderByPosition(); var shift = shiftServices.GetShiftById(shiftId); var shiftVM = new AddShiftVM() { IsCalendarView = isCalendarView, ShiftId = shift.ShiftId, DateOfShift = shift.StartTime.Date, ListEmployees = lstEmployee, AssignedShiftEmployeeId = shift.EmployeeId, AssignedShiftEmployeeFullName = shift.FullName, ShiftStartAt = shift.StartTime.ToShortTimeString(), ShiftEndAt = shift.EndTime.ToShortTimeString() }; return(PartialView("_Add_Edit_Shift", shiftVM)); } catch (Exception ex) { throw ex; } }
public ActionResult AddCalendarView(DateTime selectedDate) { IList <Employee> lstEmployee = employeeServices.GetAllEmployeeToAssignShift(selectedDate); var shift = new AddShiftVM() { DateOfShift = selectedDate, ListEmployees = lstEmployee, IsCalendarView = true }; return(PartialView("_Add_Edit_Shift", shift)); }
public ActionResult AddShiftEmployeeView(string employeeId, DateTime startDate, DateTime endDate) { string employeeFullName = employeeFullName = employeeServices.GetEmployeeById(employeeId).FullName; var shift = new AddShiftVM() { AssignedShiftEmployeeId = employeeId, AssignedShiftEmployeeFullName = employeeFullName, StartDate = startDate, EndDate = endDate, IsCalendarView = false }; return(PartialView("_Add_Edit_Shift", shift)); }