public ActionResult ApplyLeave() { ViewBag.LeaveType = LeaveServices.GetAllLeaveType(); ViewBag.LeaveDuration = LeaveServices.GetAllLeaveDuration(); LeaveModel model = new LeaveModel(); return(View(model)); }
public ActionResult Create(HolidayModel model) { ViewBag.LeaveDuration = LeaveServices.GetAllLeaveDuration(); if (ModelState.IsValid) { DateTime StartDate; DateTime EndDate; HolidayEntity ob = new HolidayEntity(); if (model.StartDate == null) { TempData[HRMWeb.Helpers.AlertStyles.Warning] = "Please Input Start Date"; return(View(model)); } if (model.EndDate == null) { TempData[HRMWeb.Helpers.AlertStyles.Warning] = "Please Input End Date"; return(View(model)); } StartDate = model.StartDate; EndDate = model.EndDate; if (StartDate > EndDate) { TempData[HRMWeb.Helpers.AlertStyles.Warning] = "Start Date can not exceed End Date"; return(View(model)); } ob.HolidayId = 0; ob.HolidayName = model.HolidayName; ob.LeaveDurationId = model.LeaveDurationId == 0 ? (int)LeaveServices.Leave_Duration.FullDay : model.LeaveDurationId; ob.StartDate = model.StartDate; ob.EndDate = model.EndDate; ob.UpdatedBy = HRMHelper.CurrentUser.UserId; ob.CreatedBy = HRMHelper.CurrentUser.UserId; int x = HolidayServices.InsertUpdateHoliday(ob); if (x > 0) { ob.HolidayId = x; TempData[HRMWeb.Helpers.AlertStyles.Success] = "Holiday Saved Successfully"; model = new HolidayModel(); } else { TempData[HRMWeb.Helpers.AlertStyles.Danger] = "Save Fails"; } } return(View(model)); }
public ActionResult EditHoliday(int?Id) { ViewBag.LeaveDuration = LeaveServices.GetAllLeaveDuration(); int HolidayId = Id == null ? 0 : (int)Id; HolidayEntity ob = HolidayServices.GetHolidayById(HolidayId); HolidayModel model = new HolidayModel(); if (ob != null) { model.HolidayId = ob.HolidayId; model.HolidayName = ob.HolidayName; model.StartDate = ob.StartDate; model.EndDate = ob.EndDate; model.LeaveDurationId = ob.LeaveDurationId; } else { return(RedirectToAction("Index")); } return(View(model)); }
public async Task <ActionResult> ApplyLeave(LeaveModel model) { ViewBag.LeaveType = LeaveServices.GetAllLeaveType(); ViewBag.LeaveDuration = LeaveServices.GetAllLeaveDuration(); if (ModelState.IsValid) { DateTime StartDate; DateTime EndDate; LeaveRequestEntity ob = new LeaveRequestEntity(); if (model.StartTime == null) { TempData[HRMWeb.Helpers.AlertStyles.Warning] = "Please Input Start Date"; return(View(model)); } if (model.EndTime == null) { TempData[HRMWeb.Helpers.AlertStyles.Warning] = "Please Input End Date"; return(View(model)); } StartDate = model.StartTime == null ? DateTime.Now.Date : (DateTime)model.StartTime; EndDate = model.EndTime == null ? DateTime.Now.Date : (DateTime)model.EndTime; if (StartDate > EndDate) { TempData[HRMWeb.Helpers.AlertStyles.Warning] = "Start Date can not exceed End Date"; return(View(model)); } ob.RequestId = 0; ob.UserId = HRMHelper.CurrentUser.UserId; ob.LeaveStatusId = (int)LeaveServices.Leave_status_Type.PendingApproval; ob.LeaveTypeId = model.LeaveTypeId; ob.LeaveDurationId = model.LeaveDurationId == 0 ? (int)LeaveServices.Leave_Duration.FullDay : model.LeaveDurationId; ob.StartTime = StartDate; ob.EndTime = EndDate; ob.Description = model.Description; ob.UpdatedBy = HRMHelper.CurrentUser.UserId; int x = LeaveServices.InsertUpdateLeave(ob); if (x > 0) { ob.RequestId = x; TempData[HRMWeb.Helpers.AlertStyles.Success] = "Leave Applied Successfully"; string MailMessage = "You applied for leave from " + ob.StartTime.ToString("MM/dd/yy") + " to " + ob.EndTime.ToString("MM/dd/yy"); string Heading = "Leave Applied"; try { UserEntity manager = UserServices.GetUserByID(HRMHelper.CurrentUser.ManagerId); string CCMail = manager.Email + "," + AppSettings.HRMail; ArrayList Urltext = new ArrayList(); ArrayList Urls = new ArrayList(); Urltext.Add("Click Here to check status"); Urls.Add(AppSettings.SiteURL + Url.Action("LeaveRecords", "Leave")); await MailUtil.MailSend(Heading, HRMHelper.CurrentUser.Name, MailMessage, Urltext, Urls, HRMHelper.CurrentUser.Email, CCMail, Heading); } catch { } } else { TempData[HRMWeb.Helpers.AlertStyles.Danger] = "Leave Apply Fails"; return(View(model)); } } model = new LeaveModel(); return(View(model)); }
public ActionResult Create() { ViewBag.LeaveDuration = LeaveServices.GetAllLeaveDuration(); return(View()); }