public IActionResult SaveDailyLeave(DailyLeave dailyLeave) { try { if (dailyLeave == null) { throw new Exception("اطلاعات مرخصی ارسال نشده است"); } if (string.IsNullOrEmpty(dailyLeave.PersianDateFrom)) { throw new Exception("تاریخ شروع ارسال نشده است"); } if (string.IsNullOrEmpty(dailyLeave.PersianDateTo)) { throw new Exception("تاریخ پایان ارسال نشده است"); } var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName); DailyLeaveManager dlm = new DailyLeaveManager(this._uow); ProjectManager pm = new ProjectManager(this._uow); UserManager um = new UserManager(this._uow); dailyLeave.UserID = currentUser.ID; dailyLeave.OrganisationId = currentUser.OrganizationUnitID; if (dailyLeave.ProjectID == Guid.Empty) { dailyLeave.ProjectID = null; } if (dailyLeave.SuccessorID == Guid.Empty) { dailyLeave.SuccessorID = null; } if (dailyLeave.ID == Guid.Empty) { dlm.Add(dailyLeave); } else { dlm.Edit(dailyLeave); } return(Ok(true)); } catch (Exception ex) { return(this.ReturnError(ex, "خطا در ذخیره مرخصی روزانه")); } }
public ActionResult Edit(DailyLeave dailyLeave) { DailyLeaveManager dlm = new DailyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); if (ModelState.IsValid) { dlm.Edit(dailyLeave); return(RedirectToAction("Index")); } ViewBag.ProjectID = new SelectList(pm.GetByUser(this.CurrentUser), "ID", "Title"); ViewBag.SuccessorID = new SelectList(um.GetAll(), "ID", "UserTitle"); return(View(dailyLeave)); }
public ActionResult Edit([Bind(Include = "ID,From,To,SuccessorID,ProjectID,Type")] DailyLeave dailyLeave) { DailyLeaveManager dlm = new DailyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); var currentUser = new UserHelper().GetCurrent(); if (ModelState.IsValid) { dlm.Edit(dailyLeave); return(RedirectToAction("Index")); } ViewBag.ProjectID = new SelectList(pm.GetByUser(currentUser), "ID", "Title"); ViewBag.SuccessorID = new SelectList(um.GetAll(), "ID", "UserTitle"); return(View(dailyLeave)); }
public IActionResult SaveDailyLeave(DailyLeave dailyLeave) { try { if (dailyLeave == null) { throw new Exception("اطلاعات مرخصی ارسال نشده است"); } if (string.IsNullOrEmpty(dailyLeave.PersianDateFrom)) { throw new Exception("تاریخ شروع ارسال نشده است"); } if (string.IsNullOrEmpty(dailyLeave.PersianDateTo)) { throw new Exception("تاریخ پایان ارسال نشده است"); } var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName); DailyLeaveManager dlm = new DailyLeaveManager(this._uow); ProjectManager pm = new ProjectManager(this._uow); UserManager um = new UserManager(this._uow); dailyLeave.UserID = currentUser.ID; dailyLeave.OrganisationId = currentUser.OrganizationUnitID; if (dailyLeave.ProjectID == Guid.Empty) { dailyLeave.ProjectID = null; } if (dailyLeave.SuccessorID == Guid.Empty) { dailyLeave.SuccessorID = null; } if (dailyLeave.ID == Guid.Empty) { dlm.Add(dailyLeave); } else { dlm.Edit(dailyLeave); } var data = new ApproveAndDenyJson() { id = dailyLeave.ID.ToString(), date = DateTime.Now, description = "", workflowStageID = dailyLeave.WorkflowStageID }; HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser); return(Ok(true)); } catch (Exception ex) { return(this.ReturnError(ex, "خطا در ذخیره مرخصی روزانه")); } }