Example #1
0
        public IActionResult SaveHourlyMission(HourlyMission hourlyMission)
        {
            try
            {
                if (hourlyMission == null)
                {
                    throw new Exception("اطلاعات ماموریت ارسال نشده است");
                }
                var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName);

                HourlyMissionManager hm = new HourlyMissionManager(this._uow);
                //ProjectManager pm = new ProjectManager(this._uow);
                //UserManager um = new UserManager(this._uow);
                hourlyMission.UserID         = currentUser.ID;
                hourlyMission.OrganisationId = currentUser.OrganizationUnitID;

                //if (hourlyMission.ProjectID == Guid.Empty)
                hourlyMission.ProjectID = null;

                if (hourlyMission.ID == Guid.Empty)
                {
                    hm.Add(hourlyMission);
                }
                else
                {
                    hm.Edit(hourlyMission);
                }

                var data = new ApproveAndDenyJson()
                {
                    id              = hourlyMission.ID.ToString(),
                    date            = DateTime.Now,
                    description     = "",
                    workflowStageID = hourlyMission.WorkflowStageID
                };



                HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser);

                return(Ok(true));
            }
            catch (Exception ex)
            {
                return(this.ReturnError(ex, "خطا در ذخیره ماموریت ساعتی"));
            }
        }
        public ActionResult Create(HourlyMission hourlyMission)
        {
            HourlyMissionManager hm = new HourlyMissionManager(UOW);
            ProjectManager       pm = new ProjectManager(UOW);
            UserManager          um = new UserManager(UOW);

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

            var firstError = ModelState.Values.SelectMany(v => v.Errors).ToList();

            if (ModelState.IsValid)
            {
                hm.Add(hourlyMission);
                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectID = new SelectList(pm.GetByUser(this.CurrentUser), "ID", "Title");

            return(View(hourlyMission));
        }
        public ActionResult Create([Bind(Include = "ID,ProjectID,PersianTimeFrom,PersianTimeTo,PersianMissionDate")] HourlyMission hourlyMission)
        {
            HourlyMissionManager hm = new HourlyMissionManager(UOW);
            ProjectManager       pm = new ProjectManager(UOW);
            UserManager          um = new UserManager(UOW);
            var currentUser         = new UserHelper().GetCurrent();

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

            var firstError = ModelState.Values.SelectMany(v => v.Errors).ToList();

            if (ModelState.IsValid)
            {
                hm.Add(hourlyMission);
                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectID = new SelectList(pm.GetByUser(currentUser), "ID", "Title");

            return(View(hourlyMission));
        }
Example #4
0
        public IActionResult SaveHourlyMission(HourlyMission hourlyMission)
        {
            try
            {
                if (hourlyMission == null)
                {
                    throw new Exception("اطلاعات ماموریت ارسال نشده است");
                }
                var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName);

                HourlyMissionManager hm = new HourlyMissionManager(this._uow);
                ProjectManager       pm = new ProjectManager(this._uow);
                UserManager          um = new UserManager(this._uow);
                hourlyMission.UserID         = currentUser.ID;
                hourlyMission.OrganisationId = currentUser.OrganizationUnitID;

                if (hourlyMission.ProjectID == Guid.Empty)
                {
                    hourlyMission.ProjectID = null;
                }

                if (hourlyMission.ID == Guid.Empty)
                {
                    hm.Add(hourlyMission);
                }
                else
                {
                    hm.Edit(hourlyMission);
                }

                return(Ok(true));
            }
            catch (Exception ex)
            {
                return(this.ReturnError(ex, "خطا در ذخیره ماموریت ساعتی"));
            }
        }