Example #1
0
    private void LoadRegion()
    {
        Region region = null;

        if (CurrentUser.Role == RoleType.Administrator)
        {
            ddlRegion.DataMember    = "Id";
            ddlRegion.DataTextField = "Name";
            ddlRegion.DataSource    = RegionService.GetRegions();
            ddlRegion.DataBind();
            region = RegionService.GetRegion(ddlRegion.SelectedValue);
        }
        else
        {
            AreaUser au = UserService.GetAreaUser(CurrentUser);
            region = au.Area.Region;
            ddlRegion.Items.Insert(0, new ListItem(au.Area.Region.Name, au.Area.Region.Name));
        }
        ddlCategories.DataSource    = CategoryService.GetCategories(region);
        ddlCategories.DataMember    = "Id";
        ddlCategories.DataTextField = "Name";
        ddlCategories.DataBind();
        ddlCategories.Items.Insert(0, new ListItem("All", "-1"));
        LoadAreas(region);
    }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (null == CurrentUser || CurrentUser.Role != RoleType.Administrator)
         {
             if (CurrentUser.Role != RoleType.RegionAdministrator)
             {
                 MasterPage.ShowErrorMessage("You are not Authorized to view this page");
                 Response.Redirect("~/Logout.aspx");
             }
         }
         if (CurrentUser.Role == RoleType.Administrator)
         {
             ddlSearchRegion.DataSource    = RegionService.GetRegions();
             ddlSearchRegion.DataMember    = "Id";
             ddlSearchRegion.DataTextField = "Name";
             ddlSearchRegion.DataBind();
             ddlSearchRegion.Items.Insert(0, new ListItem("All", "-1"));
         }
         else
         {
             lnkAttachments.Visible = false;
             AreaUser au = UserService.GetAreaUser(CurrentUser);
             ddlSearchRegion.Items.Insert(0, new ListItem(au.Area.Region.Name, au.Area.Region.Name));
         }
         LoadAreas();
         LoadSchools();
         SortDirection = SortDirection.Descending;
         SortColumn    = "FullName";
     }
 }
Example #3
0
    //public ScoreService ScoreService
    //{
    //    get
    //    {
    //        if (null == _scoreService)
    //        {
    //            IApplicationContext ctx = Spring.Context.Support.ContextRegistry.GetContext();
    //            _scoreService = ctx["ScoreService"] as ScoreService;
    //        }
    //        return _scoreService;
    //    }
    //    set { _scoreService = value; }
    //}


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (null == CurrentUser || CurrentUser.Role != RoleType.Administrator)
            {
                if (CurrentUser.Role != RoleType.RegionAdministrator)
                {
                    MasterPage.ShowErrorMessage("You are not Authorized to view this page");
                    Response.Redirect("~/Default.aspx");
                }
            }
            if (CurrentUser.Role == RoleType.Administrator)
            {
                ddlSearchRegion.DataSource    = RegionService.GetRegions();
                ddlSearchRegion.DataMember    = "Id";
                ddlSearchRegion.DataTextField = "Name";
                ddlSearchRegion.DataBind();
            }
            else
            {
                AreaUser au = UserService.GetAreaUser(CurrentUser);
                ddlSearchRegion.Items.Insert(0, new ListItem(au.Area.Region.Name, au.Area.Region.Name));
            }

            LoadScores();
        }
    }
Example #4
0
        public void RemoveUserFromArea(Area area, User userToRemove)
        {
            AreaUser toDelete = GetAreaUser(area, userToRemove);

            repository.Delete(toDelete);
            repository.Save();
        }
Example #5
0
        public void AddUserToArea(Area area, User userToAdd)
        {
            AreaUser toAdd = new AreaUser
            {
                AreaID = area.ID,
                area   = area,
                UserID = userToAdd.ID,
                user   = userToAdd
            };

            repository.Add(toAdd);
            repository.Save();
        }
Example #6
0
        public ActionResult Delete(int id, AreaUser areaUser)
        {
            try
            {
                AreaUserRepository repository = new();
                repository.Delete(areaUser);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #7
0
 public void RemoveManager(Guid areaId, Guid userId)
 {
     try
     {
         AreaUser areaManager = new AreaUser()
         {
             AreaId = areaId,
             UserId = userId
         };
         areaUserRepo.Remove(areaManager);
         areaUserRepo.Save();
     }
     catch (RepositoryInterfaceException e)
     {
         throw new BusinessLogicException(e.Message, e);
     }
 }
Example #8
0
 public void AddManager(Guid areaId, Guid userId)
 {
     try {
         User manager = userRepo.Get(userId);
         CheckIfIsManager(manager);
         Area     area        = areaRepo.Get(areaId);
         AreaUser areaManager = new AreaUser()
         {
             AreaId = areaId,
             Area   = area,
             UserId = userId,
             User   = manager
         };
         areaUserRepo.Add(areaManager);
         areaUserRepo.Save();
     }
     catch (RepositoryInterfaceException e)
     {
         throw new BusinessLogicException(e.Message, e);
     }
 }
Example #9
0
        public async Task <ActionResult> Edit(int id, AreaUser areaUser)
        {
            try
            {
                AreaRepository areaRepository = new();
                Area           area           = areaRepository.ProcurarArea(areaUser.Area.NameArea);

                CandidateRepository candidateRepository = new();
                Candidate           candidate           = candidateRepository.BuscarPorCPF(areaUser.Candidate.CPF);

                areaUser.Area.Id      = area.Id;
                areaUser.Candidate.Id = candidate.Id;

                AreaUserRepository repository = new();
                repository.Add(areaUser);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #10
0
    private void EditUser(int id)
    {
        UserInput input = UserService.GetUserProfile(id);

        Label        lblId          = modalDialog.FindControl("lblId") as Label;
        TextBox      txtFullName    = modalDialog.FindControl("txtFullName") as TextBox;
        TextBox      txtEmail       = modalDialog.FindControl("txtEmail") as TextBox;
        TextBox      txtComment     = modalDialog.FindControl("txtComment") as TextBox;
        TextBox      txtPhone       = modalDialog.FindControl("txtPhone") as TextBox;
        DropDownList ddlRoleType    = modalDialog.FindControl("ddlRoleType") as DropDownList;
        DropDownList ddlRegion      = modalDialog.FindControl("ddlRegion") as DropDownList;
        DropDownList ddlArea        = modalDialog.FindControl("ddlArea") as DropDownList;
        DropDownList ddlCategory    = modalDialog.FindControl("ddlCategory") as DropDownList;
        DropDownList ddlSchool      = modalDialog.FindControl("ddlSchool") as DropDownList;
        Label        labCustomError = modalDialog.FindControl("labCustomError") as Label;

        labCustomError.Text    = "";
        labCustomError.Visible = false;
        lblId.Text             = id.ToString();
        txtFullName.Text       = input.FullName;
        txtEmail.Text          = input.EMail;
        txtComment.Text        = input.Comment;
        txtPhone.Text          = input.Phone;
        int i = 0;

        ddlRoleType.Items.Clear();
        ddlRegion.Items.Clear();
        ddlArea.Items.Clear();
        ddlCategories.Items.Clear();
        ddlSchool.Items.Clear();


        Region region = null;

        if (CurrentUser.Role == RoleType.Administrator)
        {
            ddlRoleType.Items.Insert(i++, new ListItem("Administrator", "0", true));
            ddlRegion.DataMember    = "Id";
            ddlRegion.DataTextField = "Name";
            IList <Region> regions = RegionService.GetRegions();
            ddlRegion.DataSource = regions;
            ddlRegion.DataBind();
            region = regions[0];
        }
        else if (CurrentUser.Role == RoleType.RegionAdministrator)
        {
            AreaUser au = UserService.GetAreaUser(CurrentUser);
            ddlRegion.Items.Insert(0, new ListItem(au.Area.Region.Name, au.Area.Region.Name));
            region = au.Area.Region;
        }
        if (id == -1)
        {
            input.Role = RoleType.Nominee;
        }

        ddlRoleType.Items.Insert(i++, new ListItem("Region Administrator", "7"));
        ddlRoleType.Items.Insert(i++, new ListItem("School Coordinator", "1", true));
        ddlRoleType.Items.Insert(i++, new ListItem("Area Judge", "2"));
        ddlRoleType.Items.Insert(i++, new ListItem("Region Judge", "3", true));
        ddlRoleType.Items.Insert(i++, new ListItem("Nominee", "4"));
        ddlRoleType.Items.Insert(i++, new ListItem("Principal", "5", true));
        ddlRoleType.SelectedValue = Convert.ToInt32(input.Role).ToString();

        if (null != input && null != input.Area && input.Id > 0)
        {
            ddlRegion.SelectedValue = input.Area.Region.Name;
            ddlArea.DataMember      = "Id";
            ddlArea.DataTextField   = "Name";
            ddlArea.DataSource      = RegionService.GetAreas(input.Area.Region);
            ddlArea.DataBind();
            ddlArea.SelectedValue     = input.Area.Name;
            ddlCategory.DataMember    = "Id";
            ddlCategory.DataTextField = "Name";
            ddlCategory.DataSource    = CategoryService.GetCategories(input.Area.Region);
            ddlCategory.DataBind();
            if (null != input.Category)
            {
                ddlCategory.SelectedValue = input.Category.Name;
            }
            LoadSchools(input.Area);
            if (null != input.School)
            {
                ddlSchool.SelectedValue = input.School.Name;
            }
        }
        else
        {
            ddlRegion.SelectedValue = region.Name;
            ddlArea.DataMember      = "Id";
            ddlArea.DataTextField   = "Name";
            ddlArea.DataSource      = RegionService.GetAreas(region);
            ddlArea.DataBind();
            ddlArea.SelectedValue = region.Areas[0].Name;

            ddlCategory.DataMember    = "Id";
            ddlCategory.DataTextField = "Name";
            ddlCategory.DataSource    = CategoryService.GetCategories(region);
            ddlCategory.DataBind();
        }

        ShowDropDowns(input.Role);
        modalDialog.ShowModal();
    }