Example #1
0
        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 Create(DailyLeave dailyLeave)
        {
            DailyLeaveManager dlm = new DailyLeaveManager(UOW);
            ProjectManager    pm  = new ProjectManager(UOW);
            UserManager       um  = new UserManager(UOW);

            dailyLeave.UserID         = this.CurrentUser.ID;
            dailyLeave.OrganisationId = this.CurrentUser.OrganizationUnitID;

            if (ModelState.IsValid)
            {
                dlm.Add(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));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "ID,From,To,PersianDateFrom,PersianDateTo,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();

            dailyLeave.UserID         = currentUser.ID;
            dailyLeave.OrganisationId = currentUser.OrganizationUnitID;

            if (ModelState.IsValid)
            {
                dlm.Add(dailyLeave);
                return(RedirectToAction("Index"));
            }


            ViewBag.ProjectID   = new SelectList(pm.GetByUser(currentUser), "ID", "Title");
            ViewBag.SuccessorID = new SelectList(um.GetAll(), "ID", "UserTitle");
            return(View(dailyLeave));
        }
Example #4
0
        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, "خطا در ذخیره مرخصی روزانه"));
            }
        }