Esempio n. 1
0
        //Filter by teamId
        public List <OSC_NptCategory> GetList(_Access paramAccess)
        {
            List <OSC_NptCategory> result = new List <OSC_NptCategory>();

            try
            {
                switch (paramAccess.Role)
                {
                case "Admin":
                    result = this.idb;
                    break;

                case "Manager":
                case "Team Leader":
                case "Department Analyst":
                case "Staff":
                    result = (from list in this.idb where list.IsActive select list).ToList();
                    break;
                }
            }
            catch (Exception ex)
            {
                _err.MessageType        = "Server Error";
                _err.MessageDescription = ex.Message.ToString();
                return(result);
            }
            return(result.OrderBy(t => t.CategoryDesc).ToList());
        }
Esempio n. 2
0
 public NptTrackerController()
 {
     this._af   = new _AppFacade();
     this.a     = new _Access();
     this.nptL  = this._af.blNptCategory.idb;
     this.teamL = this._af.blTeam.idb;
     this.repL  = this._af.blRepresentative.idb;
 }
Esempio n. 3
0
        // GET: NptTracker/Create
        public ActionResult Create(long?teamId)
        {
            #region BTSS
            try
            {
                if (Session["role"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["logon_user"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["grp_id"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else
                {
                    this.a = new _Access()
                    {
                        LogonUser = Session["logon_user"].ToString(),
                        Role      = Session["role"].ToString(),
                        Group     = Session["grp_id"].ToString(),
                        CanAdd    = this._af.blAccess.CanAdd(Session["grp_id"].ToString(), module)
                    };
                    if (!this.a.CanAdd)
                    {
                        return(View("~/Views/Shared/NoAccess.cshtml"));
                    }
                    else
                    {
                        ViewBag.Access = this.a;
                    }
                }
            }
            catch (Exception ex)
            {
                _ErrorMessage err = new _ErrorMessage();
                err.MessageType        = "Server Error - NPTTrackerController";
                err.MessageDescription = ex.Message.ToString();
                ViewBag.Error          = err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            #endregion BTSS
            #region Return
            if (teamId == null)
            {
                teamId = 0;
            }
            ViewBag.Teams             = new SelectList(_af.blTeam.GetList(a), "TeamId", "TeamName");
            ViewBag.Representatives   = new SelectList(_af.blRepresentative.GetList(a).Where(t => t.TeamId == (long)teamId), "RepId", "FullName");
            ViewBag.TeamNptCategories = new SelectList(_af.blTeamNptCategories.GetList((long)teamId), "CategoryDesc", "CategoryDesc");
            return(View());

            #endregion Return
        }
Esempio n. 4
0
        //Filter by role and group access
        public List <OSC_Team> GetList(_Access paramAccess)
        {
            List <OSC_Team> result = new List <OSC_Team>();

            if (paramAccess.LogonUser == "" || paramAccess.LogonUser == null || paramAccess.Role == "" || paramAccess.Role == null)
            {
                return(result);
            }
            try
            {
                switch (paramAccess.Role)
                {
                case "Admin":
                    result = this.idb;
                    break;

                case "Staff":
                    OSC_Representative rep = this.db.Representatives.Where(t => t.PRDUserId == paramAccess.LogonUser && t.IsActive && t.IsCurrent).FirstOrDefault();
                    if (rep != null)
                    {
                        result = this.GetList().Where(t => t.TeamId == rep.TeamId && t.IsActive).ToList();
                    }
                    break;

                case "Manager":
                case "Department Analyst":
                case "Team Leader":
                    List <long> list = this.access.GetList(paramAccess.LogonUser, paramAccess.Role, "TEAM");
                    result = this.GetList().Where(t => list.Contains((long)t.TeamId) && t.IsActive).ToList();
                    break;
                }
            }
            catch (Exception ex)
            {
                _err.MessageType        = "Server Error";
                _err.MessageDescription = ex.Message.ToString();
                return(result);
            }
            return(result.OrderBy(t => t.TeamName).ToList());
        }
Esempio n. 5
0
        public ActionResult DeleteConfirmed(long id)
        {
            #region BTSS
            try
            {
                if (Session["role"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["logon_user"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["grp_id"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else
                {
                    this.a = new _Access()
                    {
                        LogonUser = Session["logon_user"].ToString(),
                        Role      = Session["role"].ToString(),
                        Group     = Session["grp_id"].ToString(),
                        CanDelete = this._af.blAccess.CanDelete(Session["grp_id"].ToString(), module)
                    };
                    if (!this.a.CanDelete)
                    {
                        return(View("~/Views/Shared/NoAccess.cshtml"));
                    }
                    else
                    {
                        ViewBag.Access = this.a;
                    }
                }
            }
            catch (Exception ex)
            {
                _ErrorMessage err = new _ErrorMessage();
                err.MessageType        = "Server Error - NPTTrackerController";
                err.MessageDescription = ex.Message.ToString();
                ViewBag.Error          = err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            #endregion BTSS
            #region Method
            OSC_ImportNPT oSC_ImportNPT = this._af.blNpt.Get(id);
            oSC_ImportNPT.DateUploaded = DateTime.Now;
            oSC_ImportNPT.UploadedBy   = a.LogonUser;
            oSC_ImportNPT.IsActive     = false;
            bool result = this._af.blNpt.Edit(oSC_ImportNPT);
            if (result == false && this._af.blNpt._err != null)
            {
                ViewBag.Error = this._af.blNpt._err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            #endregion Method
            #region Return
            ViewBag.Message = "Successfully saved!";
            return(RedirectToAction("Index"));

            #endregion Return
        }
Esempio n. 6
0
        // GET: NptTracker/Delete/5
        public ActionResult Delete(long?id)
        {
            #region BTSS
            try
            {
                if (Session["role"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["logon_user"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["grp_id"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else
                {
                    this.a = new _Access()
                    {
                        LogonUser = Session["logon_user"].ToString(),
                        Role      = Session["role"].ToString(),
                        Group     = Session["grp_id"].ToString(),
                        CanDelete = this._af.blAccess.CanDelete(Session["grp_id"].ToString(), module)
                    };
                    if (!this.a.CanDelete)
                    {
                        return(View("~/Views/Shared/NoAccess.cshtml"));
                    }
                    else
                    {
                        ViewBag.Access = this.a;
                    }
                }
            }
            catch (Exception ex)
            {
                _ErrorMessage err = new _ErrorMessage();
                err.MessageType        = "Server Error - NPTTrackerController";
                err.MessageDescription = ex.Message.ToString();
                ViewBag.Error          = err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            #endregion BTSS
            #region Method
            if (id == null)
            {
                _ErrorMessage err = new _ErrorMessage()
                {
                    MessageType        = "Server Error - NPTTrackerController",
                    MessageDescription = "Invalid use of null"
                };
                ViewBag.Error = err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            //get
            OSC_ImportNPT oSC_ImportNPT = this._af.blNpt.Get((long)id);
            //if bl npt error exist
            if (this._af.blNpt._err == null)
            {
                ViewBag.Error = this._af.blNpt._err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            //if record not exist
            if (oSC_ImportNPT == null)
            {
                return(View("~/Views/Shared/NotFound.cshtml"));
            }
            #endregion Method
            #region Return
            return(View(oSC_ImportNPT));

            #endregion Return
        }
Esempio n. 7
0
        public ActionResult Edit([Bind(Include = "NPTReportId,RepId,Activity,DateOfActivity,TimeSpent,TypeOfActivity,CreatedBy,ItemType,Path,TeamId,Month,Year,DateUploaded,UploadedBy,Source,CategoryId,SubCategoryId,IsActive")] OSC_ImportNPT oSC_ImportNPT)
        {
            #region BTSS
            try
            {
                if (Session["role"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["logon_user"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["grp_id"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else
                {
                    this.a = new _Access()
                    {
                        LogonUser = Session["logon_user"].ToString(),
                        Role      = Session["role"].ToString(),
                        Group     = Session["grp_id"].ToString(),
                        CanEdit   = this._af.blAccess.CanEdit(Session["grp_id"].ToString(), module)
                    };
                    if (!this.a.CanEdit)
                    {
                        return(View("~/Views/Shared/NoAccess.cshtml"));
                    }
                    else
                    {
                        ViewBag.Access = this.a;
                    }
                }
            }
            catch (Exception ex)
            {
                _ErrorMessage err = new _ErrorMessage();
                err.MessageType        = "Server Error - NPTTrackerController";
                err.MessageDescription = ex.Message.ToString();
                ViewBag.Error          = err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            #endregion BTSS
            #region Method
            oSC_ImportNPT.Month        = Convert.ToDateTime(oSC_ImportNPT.DateOfActivity).Month;
            oSC_ImportNPT.Year         = Convert.ToDateTime(oSC_ImportNPT.DateOfActivity).Year;
            oSC_ImportNPT.DateUploaded = DateTime.Now;
            oSC_ImportNPT.UploadedBy   = a.LogonUser;
            oSC_ImportNPT.Source       = "Manual";
            if (a.Role != "Admin")
            {
                oSC_ImportNPT.IsActive = true;
            }
            bool result = this._af.blNpt.Edit(oSC_ImportNPT);
            if (result == false && this._af.blNpt._err != null)
            {
                ViewBag.Error = this._af.blNpt._err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            #endregion Method
            #region Return
            ViewBag.Message           = "Successfully saved!";
            ViewBag.TeamNptCategories = new SelectList(_af.blTeamNptCategories.GetList((long)oSC_ImportNPT.TeamId), "CategoryDesc", "CategoryDesc");
            OSC_ImportNPT returnObj = this._af.blNpt.Get(oSC_ImportNPT.NPTReportId);
            return(View(returnObj));

            #endregion Return
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "NPTReportId,RepId,Activity,DateOfActivity,TimeSpent,TypeOfActivity,TeamId,IsActive")] OSC_ImportNPT oSC_ImportNPT)
        {
            #region BTSS
            try
            {
                if (Session["role"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["logon_user"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["grp_id"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else
                {
                    this.a = new _Access()
                    {
                        LogonUser = Session["logon_user"].ToString(),
                        Role      = Session["role"].ToString(),
                        Group     = Session["grp_id"].ToString(),
                        CanAdd    = this._af.blAccess.CanAdd(Session["grp_id"].ToString(), module)
                    };
                    if (!this.a.CanAdd)
                    {
                        return(View("~/Views/Shared/NoAccess.cshtml"));
                    }
                    else
                    {
                        ViewBag.Access = this.a;
                    }
                }
            }
            catch (Exception ex)
            {
                _ErrorMessage err = new _ErrorMessage();
                err.MessageType        = "Server Error - NPTTrackerController";
                err.MessageDescription = ex.Message.ToString();
                ViewBag.Error          = err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            #endregion BTSS
            #region Method
            oSC_ImportNPT.Month        = Convert.ToDateTime(oSC_ImportNPT.DateOfActivity).Month;
            oSC_ImportNPT.Year         = Convert.ToDateTime(oSC_ImportNPT.DateOfActivity).Year;
            oSC_ImportNPT.DateUploaded = DateTime.Now;
            oSC_ImportNPT.UploadedBy   = a.LogonUser;
            oSC_ImportNPT.IsActive     = true;
            oSC_ImportNPT.Source       = "Manual";
            bool result = this._af.blNpt.Create(oSC_ImportNPT);
            if (result == true)
            {
                ViewBag.Message = "Successfully saved!";
                return(RedirectToAction("Index"));
            }
            #endregion Method
            #region Return
            ViewBag.Err = this._af.blNpt._err;
            return(View(oSC_ImportNPT));

            #endregion Return
        }
Esempio n. 9
0
        // GET: NptTracker
        public ActionResult Index(int?page, int?pageSize, bool?filterOn, _Filter filter)
        {
            #region BTSS
            try
            {
                if (Session["role"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["logon_user"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else if (Session["grp_id"] == null)
                {
                    return(View("~/Views/Shared/SessionTimeout.cshtml"));
                }
                else
                {
                    this.a = new _Access()
                    {
                        LogonUser = Session["logon_user"].ToString(),
                        Role      = Session["role"].ToString(),
                        Group     = Session["grp_id"].ToString(),
                        CanView   = this._af.blAccess.CanView(Session["grp_id"].ToString(), module),
                        CanAdd    = this._af.blAccess.CanAdd(Session["grp_id"].ToString(), module),
                        CanEdit   = this._af.blAccess.CanEdit(Session["grp_id"].ToString(), module),
                        CanDelete = this._af.blAccess.CanDelete(Session["grp_id"].ToString(), module)
                    };
                    if (!this.a.CanView)
                    {
                        return(View("~/Views/Shared/NoAccess.cshtml"));
                    }
                    else
                    {
                        ViewBag.Access = this.a;
                    }
                }
            }
            catch (Exception ex)
            {
                _ErrorMessage err = new _ErrorMessage();
                err.MessageType        = "Server Error - NPTTrackerController";
                err.MessageDescription = ex.Message.ToString();
                ViewBag.Error          = err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            #endregion BTSS
            #region Table
            List <OSC_ImportNPT> npts = new List <OSC_ImportNPT>();
            npts = this._af.blNpt.GetList(a);
            if (npts.Count == 0 && this._af.blNpt._err != null)
            {
                ViewBag.Error = this._af.blNpt._err;
                return(View("~/Views/Shared/SomethingWentWrong.cshtml"));
            }
            #endregion Table
            #region Filters
            if (filterOn != null && filterOn == true)
            {
            }
            else
            {
                string noVal = "";
                ViewBag.Category       = noVal;
                ViewBag.Team           = noVal;
                ViewBag.Representative = noVal;
                ViewBag.DateOfActivity = noVal;
                ViewBag.TimeSpent      = noVal;
            }
            #endregion Filters
            #region Return
            int?defaultPageSize = 10;
            if (pageSize != null)
            {
                defaultPageSize = pageSize;
            }
            return(View(npts.OrderByDescending(n => n.DateOfActivity).ToPagedList(page ?? 1, (int)defaultPageSize)));

            #endregion Return
        }