public ActionResult DeleteConfirmed(Guid id) { HourlyLeaveManager hm = new HourlyLeaveManager(UOW); hm.DeleteByID(id); return(RedirectToAction("Index")); }
public ActionResult Index() { HourlyLeaveManager hl = new HourlyLeaveManager(UOW); var hourlyLeaves = hl.GetAllByUserID(this.CurrentUser.ID); return(View(new HourlyLeaveAssembler().ToJsons(hourlyLeaves.ToList()))); }
public ActionResult ShowApproves() { HourlyLeaveManager dlm = new HourlyLeaveManager(UOW); var HourlyLeaves = dlm.GetByOrganisationID(this.CurrentUser.OrganizationUnitID). Where(x => x.WorkflowStage.Order == 4); return(View(new HourlyLeaveAssembler().ToJsons(HourlyLeaves.ToList()))); }
public ActionResult DeleteConfirmed(Guid id) { HourlyLeaveManager hm = new HourlyLeaveManager(UOW); var currentUser = new UserHelper().GetCurrent(); hm.DeleteByID(id); return(RedirectToAction("Index")); }
public ActionResult ShowDenied() { HourlyLeaveManager dlm = new HourlyLeaveManager(UOW); var currentUser = new UserHelper().GetCurrent(); var HourlyLeaves = dlm.GetByOrganisationID(currentUser.OrganizationUnitID). Where(x => x.WorkflowStage.Order == 1); return(View(new HourlyLeaveAssembler().ToJsons(HourlyLeaves.ToList()))); }
public ActionResult Resend(Guid id) { HourlyLeaveManager dlm = new HourlyLeaveManager(UOW); var HourlyLeave = dlm.GetByID(id); dlm.Resend(HourlyLeave); UOW.SaveChanges(); return(RedirectToAction("ShowDenied", new { ac = "Resend" })); }
public ActionResult DenyConfirmed(Guid id) { HourlyLeaveManager dlm = new HourlyLeaveManager(UOW); var result = dlm.GetByID(id); dlm.Deny(result); UOW.SaveChanges(); return(RedirectToAction("ApproveIndex", new { ac = "Deny" })); }
public ActionResult ApproveConfirmed(Guid id) { HourlyLeaveManager dlm = new HourlyLeaveManager(UOW); var result = dlm.GetByID(id); var currentUser = new UserHelper().GetCurrent(); dlm.Approve(result); UOW.SaveChanges(); return(RedirectToAction("ApproveIndex", new { ac = "Approve" })); }
public ActionResult ApproveAll() { HourlyLeaveManager dlm = new HourlyLeaveManager(UOW); var hourlyLeaves = dlm.GetByOrganisationID(this.CurrentUser.OrganizationUnitID). Where(x => x.WorkflowStage.Order == 3); foreach (var leave in hourlyLeaves) { dlm.Approve(leave); } UOW.SaveChanges(); return(RedirectToAction("ApproveIndex", new { ac = "ApproveAll" })); }
// GET: HourlyLeaves/Details/5 public ActionResult Details(Guid id) { if (id == Guid.Empty) { return(this.StatusCode(statusCode: (int)System.Net.HttpStatusCode.BadRequest, "آی دی مرخصی ارسال نشده است")); } HourlyLeaveManager hl = new HourlyLeaveManager(UOW); HourlyLeave hourlyLeave = hl.GetByID(id); if (hourlyLeave == null) { return(this.StatusCode(statusCode: (int)System.Net.HttpStatusCode.NotFound, "مرخصی با آی دی ارسال شده یافت نشد")); } return(View(new HourlyLeaveAssembler().ToJson(hourlyLeave))); }
// GET: HourlyLeaves/Details/5 public ActionResult Details(Guid id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HourlyLeaveManager hl = new HourlyLeaveManager(UOW); HourlyLeave hourlyLeave = hl.GetByID(id); if (hourlyLeave == null) { return(HttpNotFound()); } return(View(new HourlyLeaveAssembler().ToJson(hourlyLeave))); }
public ActionResult Edit(HourlyLeave hourlyLeave) { HourlyLeaveManager hm = new HourlyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); if (ModelState.IsValid) { hm.Edit(hourlyLeave); return(RedirectToAction("Index")); } ViewBag.ProjectID = new SelectList(pm.GetByUser(this.CurrentUser), "ID", "Title"); ViewBag.SuccessorID = new SelectList(um.GetAll(), "ID", "UserTitle"); return(View(hourlyLeave)); }
public ActionResult Edit([Bind(Include = "ID,ProjectID,PersianTimeFrom,PersianTimeTo,PersianLeaveDate")] HourlyLeave hourlyLeave) { HourlyLeaveManager hm = new HourlyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); var currentUser = new UserHelper().GetCurrent(); if (ModelState.IsValid) { hm.Edit(hourlyLeave); return(RedirectToAction("Index")); } ViewBag.ProjectID = new SelectList(pm.GetByUser(currentUser), "ID", "Title"); ViewBag.SuccessorID = new SelectList(um.GetAll(), "ID", "UserTitle"); return(View(hourlyLeave)); }
public IActionResult SaveHourlyLeave(HourlyLeave hourlyLeave) { try { if (hourlyLeave == null) { throw new Exception("اطلاعات مرخصی ارسال نشده است"); } var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName); HourlyLeaveManager hm = new HourlyLeaveManager(this._uow); ProjectManager pm = new ProjectManager(this._uow); UserManager um = new UserManager(this._uow); hourlyLeave.UserId = currentUser.ID; hourlyLeave.OrganisationId = currentUser.OrganizationUnitID; //if (hourlyLeave.ProjectID == Guid.Empty) hourlyLeave.ProjectID = null; if (hourlyLeave.ID == Guid.Empty) { hm.Add(hourlyLeave); } else { hm.Edit(hourlyLeave); } var data = new ApproveAndDenyJson() { id = hourlyLeave.ID.ToString(), date = DateTime.Now, description = "", workflowStageID = hourlyLeave.WorkflowStageID }; HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser); return(Ok(true)); } catch (Exception ex) { return(this.ReturnError(ex, "خطا در ذخیره مرخصی ساعتی")); } }
public ActionResult Approve(Guid id) { HourlyLeaveManager dlm = new HourlyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); if (id == Guid.Empty) { return(this.StatusCode(statusCode: (int)System.Net.HttpStatusCode.BadRequest, "آی دی مرخصی ارسال نشده است")); } HourlyLeave hourlyLeave = dlm.GetByID(id); if (hourlyLeave == null) { return(this.StatusCode(statusCode: (int)System.Net.HttpStatusCode.NotFound, "مرخصی با آی دی ارسال شده یافت نشد")); } return(View(new HourlyLeaveAssembler().ToJson(hourlyLeave))); }
// POST: DailyLeaves/Approve/5 public ActionResult Deny(Guid id) { HourlyLeaveManager dlm = new HourlyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); var currentUser = new UserHelper().GetCurrent(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HourlyLeave hourlyLeave = dlm.GetByID(id); if (hourlyLeave == null) { return(HttpNotFound()); } return(View(new HourlyLeaveAssembler().ToJson(hourlyLeave))); }
// GET: HourlyLeaves/Edit/5 public ActionResult Edit(Guid id) { HourlyLeaveManager hm = new HourlyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); if (id == Guid.Empty) { return(this.StatusCode(statusCode: (int)System.Net.HttpStatusCode.BadRequest, "آی دی مرخصی ارسال نشده است")); } HourlyLeave hourlyLeave = hm.GetByID(id); if (hourlyLeave == null) { return(this.StatusCode(statusCode: (int)System.Net.HttpStatusCode.NotFound, "مرخصی با آی دی ارسال شده یافت نشد")); } ViewBag.ProjectID = new SelectList(pm.GetByUser(this.CurrentUser), "ID", "Title"); return(View(hourlyLeave)); }
// GET: HourlyLeaves/Edit/5 public ActionResult Edit(Guid id) { HourlyLeaveManager hm = new HourlyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); var currentUser = new UserHelper().GetCurrent(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HourlyLeave hourlyLeave = hm.GetByID(id); if (hourlyLeave == null) { return(HttpNotFound()); } ViewBag.ProjectID = new SelectList(pm.GetByUser(currentUser), "ID", "Title"); return(View(hourlyLeave)); }
public ActionResult Create(HourlyLeave hourlyLeave) { HourlyLeaveManager hm = new HourlyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); hourlyLeave.UserId = this.CurrentUser.ID; hourlyLeave.OrganisationId = this.CurrentUser.OrganizationUnitID; var firstError = ModelState.Values.SelectMany(v => v.Errors).ToList(); if (ModelState.IsValid) { hm.Add(hourlyLeave); return(RedirectToAction("Index")); } ViewBag.ProjectID = new SelectList(pm.GetByUser(this.CurrentUser), "ID", "Title"); return(View(hourlyLeave)); }
public ActionResult Create([Bind(Include = "ID,From,To,ProjectID,PersianTimeFrom,PersianTimeTo,PersianLeaveDate")] HourlyLeave hourlyLeave) { HourlyLeaveManager hm = new HourlyLeaveManager(UOW); ProjectManager pm = new ProjectManager(UOW); UserManager um = new UserManager(UOW); var currentUser = new UserHelper().GetCurrent(); hourlyLeave.UserId = currentUser.ID; hourlyLeave.OrganisationId = currentUser.OrganizationUnitID; var firstError = ModelState.Values.SelectMany(v => v.Errors).ToList(); if (ModelState.IsValid) { hm.Add(hourlyLeave); return(RedirectToAction("Index")); } ViewBag.ProjectID = new SelectList(pm.GetByUser(currentUser), "ID", "Title"); return(View(hourlyLeave)); }
public IActionResult SaveHourlyLeave(HourlyLeave hourlyLeave) { try { if (hourlyLeave == null) { throw new Exception("اطلاعات مرخصی ارسال نشده است"); } var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName); HourlyLeaveManager hm = new HourlyLeaveManager(this._uow); ProjectManager pm = new ProjectManager(this._uow); UserManager um = new UserManager(this._uow); hourlyLeave.UserId = currentUser.ID; hourlyLeave.OrganisationId = currentUser.OrganizationUnitID; if (hourlyLeave.ProjectID == Guid.Empty) { hourlyLeave.ProjectID = null; } if (hourlyLeave.ID == Guid.Empty) { hm.Add(hourlyLeave); } else { hm.Edit(hourlyLeave); } return(Ok(true)); } catch (Exception ex) { return(this.ReturnError(ex, "خطا در ذخیره مرخصی ساعتی")); } }
private void approveDenyHourlyLeave(bool isApprove, Domain.User currentUser, TimeSheetManager timeSheetManager, HourlyLeaveManager dlm, HourlyLeave dailyLeave, string userDescription) { if (dailyLeave.WorkflowStage.Type == "Final") { throw new Exception("هم اکنون تایید نهایی می باشد"); } var isManager = timeSheetManager.IsUserOrganisationMnager(dailyLeave.UserId, currentUser); if (dailyLeave.WorkflowStage.Type == "Manager" && !isManager) { throw new Exception("آیتم منتظر تایید مدیر ستادی است"); } var data = new ApproveAndDenyJson() { id = dailyLeave.ID.ToString(), date = DateTime.Now, description = userDescription, workflowStageID = dailyLeave.WorkflowStageID }; if (isApprove) { dlm.Approve(dailyLeave); HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser); } else { dlm.Deny(dailyLeave); HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser); } }
public IActionResult approveDeny(vmApproveDenyRequest request) { try { if (!this.MainChecks(request.ver, out string error)) { throw new Exception(error); } if (request.approveIds.Count == 0 && request.denyIds.Count == 0) { throw new Exception("موردی برای تایید یا رد مشخص نشده است"); } var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName); TimeSheetManager timeSheetManager = new TimeSheetManager(this._uow); if (request.type == 10) { //workhour foreach (var itemForApprove in request.approveIds) { var item = timeSheetManager.GetByID(itemForApprove.id); approveDenyWorkhour(true, currentUser, timeSheetManager, item, itemForApprove.description); } foreach (var itemForDeny in request.denyIds) { var item = timeSheetManager.GetByID(itemForDeny.id); approveDenyWorkhour(false, currentUser, timeSheetManager, item, itemForDeny.description); } } if (request.type == 1) { //ماموریت ساعتی HourlyMissionManager dlm = new HourlyMissionManager(this._uow); foreach (var itemForApprove in request.approveIds) { var dailyLeave = dlm.GetByID(itemForApprove.id); approveDenyHourlyMission(true, currentUser, timeSheetManager, dlm, dailyLeave, itemForApprove.description); } foreach (var itemForDeny in request.denyIds) { var dailyLeave = dlm.GetByID(itemForDeny.id); approveDenyHourlyMission(false, currentUser, timeSheetManager, dlm, dailyLeave, itemForDeny.description); } this._uow.SaveChanges(); } if (request.type == 2) { //مرخصی ساعتی HourlyLeaveManager dlm = new HourlyLeaveManager(this._uow); foreach (var itemForApprove in request.approveIds) { var dailyLeave = dlm.GetByID(itemForApprove.id); approveDenyHourlyLeave(true, currentUser, timeSheetManager, dlm, dailyLeave, itemForApprove.description); } foreach (var itemForDeny in request.denyIds) { var dailyLeave = dlm.GetByID(itemForDeny.id); approveDenyHourlyLeave(false, currentUser, timeSheetManager, dlm, dailyLeave, itemForDeny.description); } this._uow.SaveChanges(); } if (request.type == 3) { //مرخصی روزانه DailyLeaveManager dlm = new DailyLeaveManager(this._uow); foreach (var itemForApprove in request.approveIds) { var dailyLeave = dlm.GetByID(itemForApprove.id); approveDenyDailyLeave(true, currentUser, timeSheetManager, dlm, dailyLeave, itemForApprove.description); } foreach (var itemForDeny in request.denyIds) { var dailyLeave = dlm.GetByID(itemForDeny.id); approveDenyDailyLeave(false, currentUser, timeSheetManager, dlm, dailyLeave, itemForDeny.description); } this._uow.SaveChanges(); } return(Ok(new { message = "عملیات تایید با موفقیت انجام گردید" })); } catch (Exception ex) { return(this.ReturnError(ex, "خطا در ذخیره تایید و رد ها")); } }