public ActionResult UpdateLeave(InstructorLeaveModel updateLeave) { if (ModelState.IsValid) { var currentUser = Request.GetOwinContext().Authentication.User.Identity.GetUserId(); _instructorRepo.UpdateInstructorLeave(currentUser, updateLeave); return View("InstructorLeaves"); } return View(); }
public ActionResult NewLeaveByInstructor(InstructorLeaveModel appliedLeave) { if (ModelState.IsValid) { var currentUser = Request.GetOwinContext().Authentication.User.Identity.GetUserId(); _instructorRepo.ApplyInstructorLeave(currentUser, appliedLeave); return View("InstructorLeaves"); } return View(); }
public void UpdateInstructorLeave(string currentUser, InstructorLeaveModel updateLeave) { var appliedDetails = DataContext.Instructor_Leaves.FirstOrDefault(s => s.Id == updateLeave.Id) ?? new Instructor_Leaves(); appliedDetails.InstructorId = currentUser; appliedDetails.Reason = updateLeave.LeaveReason; appliedDetails.StartDate = updateLeave.StartDate; appliedDetails.EndDate = updateLeave.EndDate; appliedDetails.StartTime = updateLeave.StartTime; appliedDetails.EndTime = updateLeave.StopTime; appliedDetails.ModifiedDate = DateTime.Now; appliedDetails.ModifiedBy = currentUser; appliedDetails.StartTime = updateLeave.StartTime; appliedDetails.EndTime = updateLeave.StopTime; if (appliedDetails.Id == 0) { appliedDetails.CreatedDate = DateTime.Now; appliedDetails.CreatedBy = currentUser; DataContext.Instructor_Leaves.Add(appliedDetails); } SaveInDatabase(); }
public ActionResult NewLeaveByInstructor(string instructorId) { var model = new InstructorLeaveModel { StartTime = new TimeSpan(0,0,0), StopTime = new TimeSpan(23,59,0) }; return View(model); }
public void ApplyInstructorLeave(string userId, InstructorLeaveModel appliedLeave) { var appliedDetails = DataContext.Instructor_Leaves.FirstOrDefault(s => s.Id == appliedLeave.Id) ?? new Instructor_Leaves(); appliedDetails.InstructorId = userId; appliedDetails.Reason = appliedLeave.LeaveReason; appliedDetails.StartDate = appliedLeave.StartDate; appliedDetails.EndDate = appliedLeave.EndDate; appliedDetails.StartTime = appliedLeave.StartTime; appliedDetails.EndTime = appliedLeave.StopTime; appliedDetails.ModifiedDate = DateTime.Now; appliedDetails.ModifiedBy = userId; if (appliedDetails.Id == 0) { appliedDetails.CreatedDate = DateTime.Now; appliedDetails.CreatedBy = userId; DataContext.Instructor_Leaves.Add(appliedDetails); } SaveInDatabase(); }