コード例 #1
0
        //

        /* Retrieves Work Effort object with specified ID, and changes "hidden" to TRUE
         * if the end date was at least one day ago.  (note: Hidden Work Efforts don't
         * show up for employee's when they are adding a Work Effort to their timesheet,
         * but they do still show up in Manager/weManagement where they can be edited and
         * un-hidden)
         */
        public virtual ActionResult hideWorkEffort(int id)
        {
            Authentication auth = new Authentication();

            if (auth.isManager(this) || Authentication.DEBUG_bypassAuth)
            {
                WorkEffort we = WorkEffortDB.WorkEffortList.Find(id);
                if (we.endDate < DateTime.Today)
                {
                    we.hidden = true;
                    WorkEffortDB.Entry(we).State = System.Data.EntityState.Modified;
                    WorkEffortDB.SaveChanges();
                    return(RedirectToAction("WeManagement"));
                }
                else
                {
                    TempData["failedHide"] = true;
                    return(RedirectToAction("WeManagement"));
                }
            }
            else
            {
                return(View("error"));
            }
        }
コード例 #2
0
        [HttpPost, ActionName("deleteWorkEffort")] //This action MUST match the above delete function.
        public virtual ActionResult confirmedDeleteWorkEffort(int id)
        {
            Authentication auth = new Authentication();

            if (auth.isManager(this) || Authentication.DEBUG_bypassAuth)
            {
                //make sure that there aren't any hours billed to the work effort
                if (checkWeForBilledHours(id) == true)
                {
                    TempData["failedDelete"] = true;
                    return(RedirectToAction("weManagement"));
                }
                else
                {
                    WorkEffort workeffort = WorkEffortDB.WorkEffortList.Find(id);
                    //change the active status to FALSE for all PCA_WE entries for the work effort
                    deactivateAllPcaWeForWorkEffort(id);
                    //delete the work effort
                    WorkEffortDB.WorkEffortList.Remove(workeffort);
                    WorkEffortDB.SaveChanges();
                    return(RedirectToAction("weManagement"));
                }
            }
            else
            {
                return(View("error"));
            }
        }
コード例 #3
0
        public virtual ActionResult addWorkEffort(WorkEffort workeffort)
        {
            Authentication auth = new Authentication();

            if (auth.isManager(this) || Authentication.DEBUG_bypassAuth)
            {
                if (ModelState.IsValid)
                {
                    //make sure there is an end date
                    if (workeffort.endDate == null)
                    {
                        workeffort.endDate = DateTime.MaxValue;
                    }

                    //make sure the start date is before the end date
                    if (workeffort.startDate > workeffort.endDate)
                    {
                        ViewBag.divisionList       = getDivisionSelectList();
                        ViewBag.endBeforeStartFlag = true;
                        return(View(workeffort));
                    }

                    //make sure it falls within it's associated PCA code's time boundaries
                    if (verifyWeTimeBounds(workeffort, workeffort.pcaCode) == true)
                    {
                        //update WorkEffort table in database
                        WorkEffortDB.WorkEffortList.Add(workeffort);
                        WorkEffortDB.SaveChanges();

                        //add the PCA_WE association to PCA_WE table
                        PCA_WE tmpPcaWe = new PCA_WE();
                        tmpPcaWe.WE  = workeffort.ID;
                        tmpPcaWe.PCA = getPcaIdFromCode(workeffort.pcaCode);
                        tmpPcaWe.associationStartDate = DateTime.Now;
                        tmpPcaWe.associationEndDate   = DateTime.MaxValue;
                        tmpPcaWe.active = true;
                        PCA_WEDB.PCA_WEList.Add(tmpPcaWe);
                        PCA_WEDB.SaveChanges();

                        return(RedirectToAction("weManagement"));
                    }
                    else
                    {
                        ViewBag.divisionList        = getDivisionSelectList();
                        ViewBag.notWithinTimeBounds = true;
                        return(View(workeffort));
                    }
                }
                return(View("error"));
            }
            else
            {
                return(View("error"));
            }
        }
コード例 #4
0
        public virtual ActionResult editWorkEffort(WorkEffort workeffort)
        {
            Authentication auth = new Authentication();

            if (auth.isManager(this) || Authentication.DEBUG_bypassAuth)
            {
                if (ModelState.IsValid)
                {
                    //make sure the start date is before the end date
                    if (workeffort.startDate > workeffort.endDate)
                    {
                        ViewBag.endBeforeStartFlag = true;
                        ViewBag.pcaList            = getWePcaCodesSelectList(workeffort);
                        Authentication newAuth = new Authentication();
                        if (newAuth.isAdmin(this))
                        {
                            ViewBag.adminFlag = true;
                        }
                        return(View(workeffort));
                    }

                    //make sure it falls within it's associated PCA code's time boundaries
                    if (verifyWeTimeBounds(workeffort, workeffort.pcaCode) == true)
                    {
                        WorkEffortDB.WorkEffortList.Add(workeffort);
                        WorkEffortDB.Entry(workeffort).State = System.Data.EntityState.Modified;
                        WorkEffortDB.SaveChanges();
                        return(RedirectToAction("weManagement"));
                    }
                    else
                    {
                        ViewBag.notWithinTimeBounds = true;
                        ViewBag.pcaList             = getWePcaCodesSelectList(workeffort);
                        Authentication newAuth = new Authentication();
                        if (newAuth.isAdmin(this))
                        {
                            ViewBag.adminFlag = true;
                        }
                        return(View(workeffort));
                    }
                }
                return(View(workeffort));
            }
            else
            {
                return(View("error"));
            }
        }