コード例 #1
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
        //
        /* Retrieves all PcaCode objects for the specified division and sends them to the
         * view as a list, along with a division selection list (for narrowing results)
         * and current division name.
         */
        public ActionResult maintainPCA(string division = null)
        {
            Authentication auth = new Authentication();
            if(auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
            {
                ViewBag.divisionList = getDivisionSelectList();

                if (TempData["failedPcaDelete"] != null)
                {
                    ViewBag.failedPcaDelete = true;
                }
                if ((division == null) || (division.CompareTo("All") == 0))
                {
                    ViewBag.division = "All";
                    return View(PcaCodeDB.PcaCodeList.ToList());
                }
                else
                {
                    ViewBag.division = division;
                    var pcaList = from p in PcaCodeDB.PcaCodeList
                                  where (p.division.CompareTo(division) == 0)
                                  select p;
                    return View(pcaList.ToList());
                }   
            }
            else
            {
                return View("error");
            }
        }
コード例 #2
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public override ActionResult Index()
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         return View();
     }
     else
     {
         return View("error");
     }
 }
コード例 #3
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public virtual ActionResult addPCA()
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         ViewBag.divisionList = getDivisionSelectList();
         return View(new PcaCode());
     }
     else
     {
         return View("error");
     }
 }
コード例 #4
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
        public virtual ActionResult addUser(AddUserModel user)
        {
            Authentication auth = new Authentication();
            if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
            {
                if (ModelState.IsValid)
                {
                    LDAPConnection newConnection = new LDAPConnection();
                    List<string> userInfo = newConnection.create(user.UserName);

                    //Code here for creating TARSUser object; this will require
                    // changing the LDAPConnection.create function to only 
                    // return the user information that is pertinent to TARS
                    /*
                    var userEntry = new TARSUser();
                    userEntry.userName = userInfo[1];
                    TARSUserDB.TARSUserList.Add(userEntry);
                    */

                    return RedirectToAction("userMaintanence");
                }
                return View(user);
            }
            else
            {
                return View("error");
            }
        }
コード例 #5
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 //
 /* Retrieves the Timesheet object for the specified employee and reference date,
  * changes "locked", "approved", and "submitted" fields to FALSE, and saves the
  * changes in the database.
  */
 public void adminUnlockTimesheet(string username, DateTime refDate)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         Timesheet tmpTs = new Timesheet();
         var searchTs = from t in TimesheetDB.TimesheetList
                        where (t.worker.CompareTo(username) == 0)
                        where t.periodStart <= refDate
                        where t.periodEnd >= refDate
                        select t;
         foreach (var item in searchTs)
         {
             tmpTs = item;
             tmpTs.locked = false;
             tmpTs.approved = false;
             tmpTs.submitted = false;
         }
         //save changes in database
         TimesheetDB.Entry(tmpTs).State = System.Data.EntityState.Modified;
         TimesheetDB.SaveChanges();
     }
     return;
 }
コード例 #6
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 //
 // Retrieves all of the Holidays objects and sends them to the view.
 public ActionResult viewHolidays()
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         List<Holidays> holidays = HolidaysDB.HolidaysList.ToList();
         return View(holidays);
     }
     else
     {
         return View("error");
     }
 }
コード例 #7
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
        public virtual ActionResult editPCA(PcaCode pcacode)
        {
            Authentication auth = new Authentication();
            if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
            {
                //make sure startDate is prior to endDate 
                if (pcacode.startDate > pcacode.endDate)
                {
                    ViewBag.endBeforeStartFlag = true;
                    ViewBag.divisionList = getDivisionSelectList();
                    return View(pcacode);
                }
                
                /* Make sure that the dates don't overlap if there is another PCA with the same
                 * code in the same division
                 */
                if (pcaCheckIfDuplicate(pcacode) == true)
                {
                    ViewBag.duplicatePcaFlag = true;
                    ViewBag.divisionList = getDivisionSelectList();
                    return View(pcacode);
                }

                TempData["tmpPcaCode"] = pcacode;
                return RedirectToAction("confirmEditPCA");
            }
            else
            {
                return View("error");
            }
        }
コード例 #8
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 //
 /* Retrieves all TARSUser objects of employees that work for the specified departement 
  * within the Information Technology division and sends them to the view as a list. If 
  * department is null, it retrieves all employees in the division.
  */
 public ActionResult viewTimesheetStatuses(DateTime refDate, string department = null)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         string division = getUserDivision();
         IEnumerable<TARSUser> employees = getDivisionEmployeeObjList(division, department);
         ViewBag.division = division;
         ViewBag.departmentList = getDepartmentSelectList(division);
         ViewBag.refDate = refDate;
         ViewBag.refSunday = refDate.StartOfWeek(DayOfWeek.Sunday);
         ViewBag.refPayPeriod = getPayPeriod(refDate);
         return View(employees);
     }
     else
     {
         return View("error");
     }
 }
コード例 #9
0
        //
        /* Returns title that is shown when hovering over a timesheet day cell in 
         * viewTimesheet view. If the timesheet is submitted or locked, then the title
         * will reflect that (unless user is an Admin).  Otherwise, it will show 
         * "Add/Edit Hours"
         */
        public virtual string getTimesheetDayCellTitle(Timesheet ts)
        {
            string title = "";
            Authentication auth = new Authentication();

            if ( (ts.approved == true) || (ts.locked == true) )
            {
                if (auth.isAdmin(this))
                {
                    title = "Admin: Add/Edit Hours";
                }
                else
                {
                    title = getTimesheetStatus(ts.worker, ts.periodStart);
                }
            }
            else
            {
                title = "Add/Edit Hours";
            }
            return title;
        }
コード例 #10
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");
            }
        }
コード例 #11
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public virtual ActionResult editHoliday(Holidays holiday)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         HolidaysDB.Entry(holiday).State = System.Data.EntityState.Modified;
         HolidaysDB.SaveChanges();
         return RedirectToAction("viewHolidays");
     }
     else
     {
         return View("error");
     }
 }
コード例 #12
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 [HttpPost, ActionName("deleteHoliday")] //This action MUST match the above delete function.
 public virtual ActionResult confirmDeleteHoliday(int id)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         Holidays holiday = HolidaysDB.HolidaysList.Find(id);
         HolidaysDB.HolidaysList.Remove(holiday);
         HolidaysDB.SaveChanges();
         return RedirectToAction("viewHolidays");
     }
     else
     {
         return View("error");
     }
 }
コード例 #13
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 // NOT YET IMPLEMENTED
 public ActionResult addUser()
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         ViewBag.divisionList = getDivisionSelectList();
         return View(new AddUserModel());
     }
     else
     {
         return View("error");
     }
 }
コード例 #14
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public virtual ActionResult addHoliday()
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         return View(new Holidays());
     }
     else
     {
         return View("error");
     }
 }
コード例 #15
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 //
 // Retrieves all TARSUser objects and sends them to the view as a list
 public ActionResult userMaintanence()
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         return View(TARSUserDB.TARSUserList.ToList());
     }
     else
     {
         return View("error");
     }
 }
コード例 #16
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 [HttpPost, ActionName("deletePCA")] //This action MUST match the above delete function.
 public virtual ActionResult confirmDeletePCA(int id)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         //make sure there are no work efforts attached to the PCA
         if (checkPcaForAttachedWorkEfforts(id) == true)
         {
             TempData["failedPcaDelete"] = true;
             return RedirectToAction("maintainPCA");
         }
         else
         {
             PcaCode pcacode = PcaCodeDB.PcaCodeList.Find(id);
             PcaCodeDB.PcaCodeList.Remove(pcacode);
             PcaCodeDB.SaveChanges();
             return RedirectToAction("maintainPCA");
         }
     }
     else
     {
         return View("error");
     }
 }
コード例 #17
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public virtual ActionResult deletePCA(int id)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         PcaCode pcacode = PcaCodeDB.PcaCodeList.Find(id);
         return View(pcacode);
     }
     else
     {
         return View("error");
     }
 }
コード例 #18
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
        public virtual ActionResult confirmEditPCA(PcaCode pcacode)
        {
            Authentication auth = new Authentication();
            if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
            {

                if (ModelState.IsValid)
                {
                    PcaCodeDB.PcaCodeList.Add(pcacode);
                    PcaCodeDB.Entry(pcacode).State = System.Data.EntityState.Modified;
                    PcaCodeDB.SaveChanges();
                }
                return RedirectToAction("maintainPCA");
            }
            else
            {
                return View("error");
            }
        }
コード例 #19
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public virtual ActionResult confirmEditPCA()
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         ViewBag.divisionList = getDivisionSelectList();
         return View(TempData["tmpPcaCode"]);
     }
     else
     {
         return View("error");
     }
 }
コード例 #20
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public virtual ActionResult addHoliday(Holidays holiday)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         HolidaysDB.HolidaysList.Add(holiday);
         HolidaysDB.SaveChanges();
         return RedirectToAction("viewHolidays");
     }
     else
     {
         return View("error");
     }
 }
コード例 #21
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 //
 // NOT YET IMPLEMENTED
 public ActionResult endDateTARSUSer()
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         return View();
     }
     else
     {
         return View("error");
     }
 }
コード例 #22
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public virtual ActionResult deleteHoliday(int id)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         Holidays holiday = HolidaysDB.HolidaysList.Find(id);
         return View(holiday);
     }
     else
     {
         return View("error");
     }
 }
コード例 #23
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
        public virtual ActionResult addPCA_WE(PCA_WE pca_we)
        {
            Authentication auth = new Authentication();
            if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
            {
                //The view actually passed the PCA code instead of the ID, so set the ID to the correct value
                pca_we.PCA = getPcaIdFromCode(pca_we.PCA);

                WorkEffort effort = WorkEffortDB.WorkEffortList.Find(pca_we.WE);
                ViewBag.workEffortDescription = effort.description;
                PcaCode pcaObj = PcaCodeDB.PcaCodeList.Find(pca_we.PCA);

                //make sure it falls within it's associated PCA code's time boundaries
                if (verifyWeTimeBounds(effort, pcaObj.code) == true)
                {
                    //Make sure it's not a duplicate entry before adding to database
                    if (checkIfDuplicatePcaWe(pca_we) == false)
                    {
                        //update PCA_WE table
                        PCA_WEDB.PCA_WEList.Add(pca_we);
                        PCA_WEDB.Entry(pca_we).State = System.Data.EntityState.Added;
                        PCA_WEDB.SaveChanges();
                    }
                    return RedirectToAction("editWorkEffort", "Manager", new { id = pca_we.WE });
                }
                ViewBag.divisionList = getDivisionSelectList();
                ViewBag.workEffortId = effort.ID;
                ViewBag.outOfPcaTimeBounds = true;
                return View(pca_we);
            }
            else
            {
                return View("error");
            }
        }
コード例 #24
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
        public virtual ActionResult addPCA(PcaCode pcacode)
        {
            Authentication auth = new Authentication();
            if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
            {
                if (ModelState.IsValid)
                {
                    if (pcacode.endDate == null)
                    {
                        pcacode.endDate = DateTime.MaxValue;
                    }
                    //make sure the start date is before the end date
                    if (pcacode.startDate > pcacode.endDate)
                    {
                        ViewBag.endBeforeStartFlag = true;
                        ViewBag.divisionList = getDivisionSelectList();
                        return View(pcacode);
                    }

                    /* Make sure that the dates don't overlap if there is another PCA with the same
                     * code in the same division
                     */
                    if (pcaCheckIfDuplicate(pcacode) == false)
                    {
                        PcaCodeDB.PcaCodeList.Add(pcacode);
                        PcaCodeDB.SaveChanges();
                        return RedirectToAction("maintainPCA");
                    }
                    else
                    {
                        ViewBag.duplicatePcaFlag = true;
                        ViewBag.divisionList = getDivisionSelectList();
                        return View(pcacode);
                    }
                }
                return View(pcacode);
            }
            else
            {
                return View("error");
            }
        }
コード例 #25
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public virtual ActionResult deletePCA_WE(int weID)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         WorkEffort we = WorkEffortDB.WorkEffortList.Find(weID);
         ViewBag.workEffortDescription = we.description;
         ViewBag.workEffortId = weID;
         ViewBag.pcaList = getWePcaCodesSelectList(we);
         return View();
     }
     else
     {
         return View("error");
     }
 }
コード例 #26
0
        public virtual ActionResult editWorkEffort(int id)
        {
            Authentication auth = new Authentication();
            if (auth.isManager(this) || Authentication.DEBUG_bypassAuth)
            {
                WorkEffort workeffort = WorkEffortDB.WorkEffortList.Find(id);
                ViewBag.pcaList = getWePcaCodesSelectList(workeffort);

                Authentication newAuth = new Authentication();
                if (newAuth.isAdmin(this))
                {
                    ViewBag.adminFlag = true;
                }
                return View(workeffort);
            }
            else
            {
                return View("error");
            } 
        }
コード例 #27
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
        public virtual ActionResult deletePCA_WE(PCA_WE pca_we)
        {
            Authentication auth = new Authentication();
            if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
            {
                //The view actually passed the PCA code instead of the ID, so set the ID to the correct value
                pca_we.PCA = getPcaIdFromCode(pca_we.PCA);
                int count = 0;

                PCA_WE tmpPcaWe = new PCA_WE();
                var searchPcaWe = from p in PCA_WEDB.PCA_WEList
                                  where p.WE == pca_we.WE
                                  where p.active == true
                                  select p;
                foreach (var item in searchPcaWe)
                {
                    //This if-statement will only be true once
                    if (item.PCA == pca_we.PCA)
                    {
                        tmpPcaWe = PCA_WEDB.PCA_WEList.Find(item.ID);
                    }
                    count++;
                }

                if (count > 1)
                {
                    //deactivate and set the end date for the PCA_WE entry
                    tmpPcaWe.active = false;
                    tmpPcaWe.associationEndDate = DateTime.Now;
                    // save changes in database
                    PCA_WEDB.Entry(tmpPcaWe).State = System.Data.EntityState.Modified;
                    PCA_WEDB.SaveChanges();
                    return RedirectToAction("weManagement", "Manager");
                }

                ViewBag.lastPcaFlag = true;
                WorkEffort we = WorkEffortDB.WorkEffortList.Find(pca_we.WE);
                ViewBag.workEffortDescription = we.description;
                ViewBag.workEffortId = we.ID;
                ViewBag.pcaList = getWePcaCodesSelectList(we);
                return View();
            }
            else
            {
                return View("error");
            }
        }
コード例 #28
0
 public virtual ActionResult managerEditHours(int hrsID, int tsID)
 {
     Authentication auth = new Authentication();
     if (auth.isManager(this) || Authentication.DEBUG_bypassAuth)
     {
         Hours hours = HoursDB.HoursList.Find(hrsID);
         WorkEffort we = WorkEffortDB.WorkEffortList.Find(hours.workEffortID);
         Timesheet timesheet = TimesheetDB.TimesheetList.Find(tsID);
         ViewBag.timesheetLockedFlag = timesheet.locked;
         Authentication newAuth = new Authentication();
         bool adminFlag = newAuth.isAdmin(this);
         ViewBag.adminFlag = adminFlag;
         ViewBag.workEffort = we;
         ViewBag.timeCodeList = getTimeCodeList();
         return View(hours);
     }
     else
     {
         return View("error");
     }
 }
コード例 #29
0
ファイル: AdminController.cs プロジェクト: ICBM/TARS
 public virtual ActionResult editPCA(int id)
 {
     Authentication auth = new Authentication();
     if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth)
     {
         PcaCode pcacode = PcaCodeDB.PcaCodeList.Find(id);
         ViewBag.divisionList = getDivisionSelectList();
         return View(pcacode);
     }
     else
     {
         return View("error");
     }
 }