// GET: /CreateUserForTeam
        public ActionResult CreateUserForTeam(int id)
        {
            Team group = new Team();

            group = teamRepository.GetTeam(id);

            //Check Exists
            if (group == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }
            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTeam(id))
            {
                return(View("Error"));
            }

            //Show Create Form
            SystemUserTeam systemUserTeam = new SystemUserTeam();

            systemUserTeam.TeamId = id;


            systemUserTeamRepository.EditForDisplay(systemUserTeam);
            return(View(systemUserTeam));
        }
        public ActionResult Delete(int id, string systemUserGuid, string from)
        {
            //Show Create Form
            SystemUserTeam systemUserTeam = new SystemUserTeam();

            systemUserTeam = systemUserTeamRepository.GetItem(id, systemUserGuid);

            //Check Exists
            if (systemUserTeam == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }
            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTeam(id))
            {
                return(View("Error"));
            }

            ViewData["From"] = from;
            systemUserTeamRepository.EditForDisplay(systemUserTeam);
            return(View(systemUserTeam));
        }
Beispiel #3
0
        public ActionResult DeleteTeam(int teamId, string id, FormCollection collection)
        {
            SystemUserTeamRepository systemUserTeamRepository = new SystemUserTeamRepository();
            SystemUserTeam           systemUserTeam           = new SystemUserTeam();

            systemUserTeam.TeamId         = teamId;
            systemUserTeam.SystemUserGuid = id;

            //Get SystemUser
            SystemUser systemUser = new SystemUser();

            systemUser = systemUserRepository.GetUserBySystemUserGuid(id);

            //Check Exists
            if (systemUser == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }
            //AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTeam(teamId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            systemUserRepository.DeleteTeam(systemUserTeam);

            //Return
            ViewData["NewSortOrder"] = 0;
            return(RedirectToAction("ListTeams", new { id = systemUserTeam.SystemUserGuid }));
        }
Beispiel #4
0
        public ActionResult DeleteTeam(int teamId, string id)
        {
            //Get SystemUser
            SystemUser systemUser = new SystemUser();

            systemUser = systemUserRepository.GetUserBySystemUserGuid(id);

            //Check Exists
            if (systemUser == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }

            //AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTeam(teamId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Show Create Form
            SystemUserTeam systemUserTeam = new SystemUserTeam();

            systemUserTeam.SystemUserGuid = id;
            systemUserTeam.TeamId         = teamId;

            SystemUserTeamRepository systemUserTeamRepository = new SystemUserTeamRepository();

            systemUserTeamRepository.EditForDisplay(systemUserTeam);
            return(View(systemUserTeam));
        }
        //Delete Team from DB
        public void DeleteTeam(SystemUserTeam systemUserTeam)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeleteSystemUserTeam_v1(
                systemUserTeam.SystemUserGuid,
                systemUserTeam.TeamId
                );
        }
        public ActionResult CreateTeamForUser(string systemUserGuid, int teamId)
        {
            SystemUserTeam systemUserTeam = new SystemUserTeam();

            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTeam(teamId))
            {
                return(View("Error"));
            }

            //Update Model From Form + Validate against DB
            try
            {
                UpdateModel(systemUserTeam);
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            //Database Update
            try
            {
                systemUserTeamRepository.Add(systemUserTeam);
            }
            catch (SqlException ex)
            {
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }


            ViewData["NewSortOrder"] = 0;
            return(RedirectToRoute("Main", new { controller = "SystemUser", action = "ListTeams", id = systemUserGuid }));
        }
        public ActionResult Delete(int id, string from, string systemUserGuid, FormCollection collection)
        {
            SystemUserTeam systemUserTeam = new SystemUserTeam();

            systemUserTeam = systemUserTeamRepository.GetItem(id, systemUserGuid);

            //Check Exists
            if (systemUserTeam == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }
            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToTeam(id))
            {
                return(View("Error"));
            }

            //Delete Item
            try
            {
                systemUserTeam.VersionNumber = Int32.Parse(collection["VersionNumber"]);
                systemUserTeamRepository.Delete(systemUserTeam);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/SystemUserTeam.mvc/Delete/" + systemUserTeam.TeamId.ToString() + "&systemUserGuid=" + systemUserTeam.SystemUserGuid.ToString();
                    return(View("VersionError"));
                }
                //Generic Error
                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }
            if (from == "Team")
            {
                return(RedirectToRoute("Default", new { controller = "Team", action = "ListSystemUsers", id = id }));
            }
            else
            {
                return(RedirectToRoute("Main", new { controller = "SystemUser", action = "ListTeams", id = systemUserGuid }));
            }
        }
Beispiel #8
0
        //Add Data From Linked Tables for Display
        public void EditForDisplay(SystemUserTeam systemUserTeam)
        {
            SystemUserRepository systemUserRepository = new SystemUserRepository();
            SystemUser           systemUser           = new SystemUser();

            systemUser = systemUserRepository.GetUserBySystemUserGuid(systemUserTeam.SystemUserGuid);
            if (systemUser != null)
            {
                systemUserTeam.SystemUserName = (systemUser.LastName + ", " + systemUser.FirstName + " " + systemUser.MiddleName).Replace("  ", " ");
            }

            TeamRepository teamRepository = new TeamRepository();
            Team           team           = new Team();

            team = teamRepository.GetTeam(systemUserTeam.TeamId);
            if (team != null)
            {
                systemUserTeam.TeamName = team.TeamName;
            }
        }
        // GET: /CreateUserForTeam
        public ActionResult CreateTeamForUser(string id)
        {
            SystemUser systemUser = new SystemUser();

            systemUser = systemUserRepository.GetUserBySystemUserGuid(id);

            //Check Exists
            if (systemUser == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }

            //Show Create Form
            SystemUserTeam systemUserTeam = new SystemUserTeam();

            systemUserTeam.SystemUserGuid = id;


            systemUserTeamRepository.EditForDisplay(systemUserTeam);
            return(View(systemUserTeam));
        }