Beispiel #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"));
            }
        }
Beispiel #2
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"));
            }
        }