Exemple #1
0
        public ActionResult ShowShop()
        {
            List <Parser>      parse = new List <Parser>();
            CustomRoleProvider l     = new CustomRoleProvider();
            bool con   = l.IsUserInRole(User.Identity.Name, "User");
            bool admin = l.IsUserInRole(User.Identity.Name, "Admin");

            if (admin)
            {
                return(RedirectToAction("Andex", "Admin"));
            }
            if (!con)
            {
                return(RedirectToAction("Index", "Home"));
            }

            using (botEntities3 bd = new botEntities3())
            {
                string       u    = User.Identity.Name;
                Users        user = bd.Users.Where(x => x.Email == u).First();
                List <Token> k    = bd.Token.Where(x => x.UserID == user.Id).ToList();
                foreach (Token m in k)
                {
                    List <Category> list = m.Category.ToList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        Parser px = new Parser(list[i]);
                        px.p = list[i].Product.ToList();
                        parse.Add(px);
                    }
                }
            }
            return(View(parse));
        }
        public IEnumerable GetAssessmentFormInfo(int id)
        {
            string currentUserId = CustomRoleProvider.GetUserId(UnitOfWork);
            var    source        = (from assessment in UnitOfWork.AssessmentRepository.Get()
                                    join techLead in UnitOfWork.UserRepository.Get() on assessment.TechLeadId equals techLead.Id into ulist
                                    from techLead in ulist.DefaultIfEmpty()
                                    join coordinator in UnitOfWork.UserRepository.Get() on assessment.CoordinatorId equals coordinator.Id into wlist
                                    from coordinator in wlist.DefaultIfEmpty()
                                    join projectManager in UnitOfWork.UserRepository.Get() on assessment.ProjectManagerId equals projectManager.Id into vlist
                                    from projectManager in vlist.DefaultIfEmpty()
                                    where assessment.Id == id
                                    select new
            {
                teachLeadName = techLead.Name,
                coordinatorName = coordinator.Name,
                projectManagerName = projectManager.Name,
                assessmentName = assessment.Name,
                assessmentVersion = assessment.Version,
                assessmentUnit = assessment.Unit,
                assessmentImprovements = assessment.Improvements,
                assessmentServiceQualityScore = assessment.ServiceQualityScore,
                assessmentURL = assessment.URL,
                assessmentCoordinatorTime = assessment.CoordinatorTime,
                assessmentExpertTime = assessment.ExpertTime,
                assessmentStartDate = assessment.StartDate,
                assessmentFinishDate = assessment.FinishDate,
                assessmentCoordinatoorId = assessment.CoordinatorId,
                currentUserId = currentUserId
            }).ToList();

            return(source);
        }
Exemple #3
0
 public void SetUserProperties(string userName)
 {
     if (userName != string.Empty)
     {
         using (EcommGroceryDataContext dataContext = new EcommGroceryDataContext())
         {
             var user = (from c in dataContext.Users
                         where c.UserName == userName && c.IsDeleted == false
                         select c).FirstOrDefault();
             if (user != null)
             {
                 UserExist        = true;
                 UserId           = user.UserId;
                 MobileNumber     = user.MobileNumber;
                 EmailId          = user.EmailId;
                 Password         = user.Password;
                 Status           = user.Status;
                 UserName         = user.UserName;
                 RoleId           = user.RoleId;
                 RegistrationDate = user.RegistrationDate == null ? DateTime.MinValue : Convert.ToDateTime(user.RegistrationDate);
                 IsAccountLocked  = user.Status;
                 AlternateNumber  = user.AlternateNumber;
                 UserRoles        = new CustomRoleProvider().GetRolesForUser(user.UserName);
             }
         }
     }
 }
Exemple #4
0
        private void ManageUsers_Load(object sender, EventArgs e)
        {
            btnAddOneUser.Enabled    = false;
            btnRemoveOneUser.Enabled = false;

            rdAddInAllRoles.Checked = false;
            rdAddInOneRole.Checked  = true;

            // Initialise Custom Provider
            userProvider = (CustomMembershipProvider)Membership.Providers["CustomMembershipProvider"];
            roleProvider = (CustomRoleProvider)Roles.Providers["CustomRoleProvider"];

            //Initialise connection string
            string connectionString = ConfigurationManager.ConnectionStrings["SQLServerConnectionString"].ConnectionString;

            ImplementCustomConnection.Instance.Initialise(connectionString, CustomConnectionType.SQLServer);

            try
            {
                loadUsers();
                loadRoles();
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show("Unable to load Users or Roles from Datasource, " + ex.Message, "Loading users and roles", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Unable to load Users or Roles from Datasource, " + ex.Message, "Loading users and roles", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to load Users or Roles from Datasource, " + ex.Message, "Loading users and roles", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #5
0
        public ActionResult ShowRecycle()
        {
            CustomRoleProvider l = new CustomRoleProvider();
            bool con             = l.IsUserInRole(User.Identity.Name, "User");

            if (!con)
            {
                return(RedirectToAction("Index", "Home"));
            }
            List <List <Recycle> > res = new List <List <Recycle> >();

            using (botEntities3 bd = new botEntities3())
            {
                string       u    = User.Identity.Name;
                Users        user = bd.Users.Where(x => x.Email == u).First();
                List <Token> k    = bd.Token.Where(x => x.UserID == user.Id).ToList();

                foreach (var z in k)
                {
                    res.Add(bd.Recycle.Where(x => x.TokenId == z.Id).ToList());
                }
            }

            return(View(res));
        }
    public bool Evaluate(EvaluationContext evaluationContext, ref object state)
    {
        // will hold the combined roles
        List <string> roles = new List <string>();

        // get the authenticated client identity
        IIdentity client = GetClientIdentity(evaluationContext);

        var config = new NameValueCollection();


        config.Add("applicationName", "/application_name");
        config.Add("connectionStringName", "APPSEC_ASPNET");

        var roleProvider = new CustomRoleProvider();

        roleProvider.Initialize("CustomRoleProvider", config);

        roles.AddRange(roleProvider.GetRolesForUser(client.Name));


        evaluationContext.Properties["Principal"] =
            new UserPrincipal(client, roles.ToArray());


        return(true);
    }
Exemple #7
0
        public ActionResult DeleteFromRecycle(string namep, string namecat, string username)
        {
            try
            {
                CustomRoleProvider l = new CustomRoleProvider();
                bool con             = l.IsUserInRole(User.Identity.Name, "User");
                if (!con)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                using (botEntities3 bd = new botEntities3())
                {
                    string  u    = User.Identity.Name;
                    Users   user = bd.Users.Where(x => x.Email == u).First();
                    Token   m    = bd.Token.Where(x => x.UserID == user.Id).First();
                    Recycle res  = bd.Recycle.Where(x => x.NameProduct == namep).Where(x => x.NameCategory == namecat).Where(x => x.TokenId == m.Id).Where(x => x.UserName == username).First();
                    bd.Recycle.Remove(res);
                    bd.SaveChanges();
                }
            }
            catch
            {
            }
            return(RedirectToAction("ShowRecycle", "Admin"));
        }
Exemple #8
0
        public ActionResult Andex()
        {
            CustomRoleProvider l = new CustomRoleProvider();
            bool admin           = l.IsUserInRole(User.Identity.Name, "Admin");

            if (!admin)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
Exemple #9
0
        public ActionResult AddElement()
        {
            CustomRoleProvider l = new CustomRoleProvider();
            bool con             = l.IsUserInRole(User.Identity.Name, "User");

            if (!con)
            {
                return(View("Index", "Home"));
            }

            return(View());
        }
Exemple #10
0
        public ActionResult ApproveUser(viewUser user)
        {
            CMSService.ApproveUser(user);
            viewUser getUser = CMSService.GetUser(user.UserId);

            if (user.IsDisApproved != true)
            {
                if (getUser != null)
                {
                    string AMRoleName = CMSService.GetRoles().Where(r => r.Id == getUser.RoleId).FirstOrDefault().Description;


                    CustomRoleProvider crp = new CustomRoleProvider();


                    string appName = ConfigurationManager.AppSettings["ApplicationName"];

                    string un = getUser.UserName;

                    rsac.AddUsersToRoles(appName, un, AMRoleName);
                }


                List <MailAddress> EMails = new List <MailAddress>();

                EMails.Add(new MailAddress(getUser.Email, "to"));

                string Message = "Registration for the user " + getUser.UserName + " has been approved.";

                string Subject = "APS Case Management System Registration: Approved";

                SendEmail(EMails, Message, Subject);
            }
            else
            {
                List <MailAddress> EMails = new List <MailAddress>();

                EMails.Add(new MailAddress(getUser.Email, "to"));

                string Message = "For user:"******". Your access to the Illinois Department on Aging Office (IDoA) of Adult Protective Services Case Management System has been denied for the following reason: " + user.DisApprovalMessage + ". Please contact either your Supervisor or if you are a Supervisor contact your IDoA liaison.";



                string Subject = "APS Case Management System Registration: Denied";

                SendEmail(EMails, Message, Subject);
            }

            return(RedirectToAction("UserAdmin"));
        }
Exemple #11
0
 private bool Role(HttpContextBase httpContext)
 {
     if (allowedRoles.Length > 0)
     {
         for (int i = 0; i < allowedRoles.Length; i++)
         {
             if (CustomRoleProvider.GetRolesForUser(unit) == allowedRoles[i])
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #12
0
 public ActionResult Index()
 {
     //Autoadding new User to database if User attends web application at first time
     try
     {
         CustomRoleProvider.UserValidation(unit);
         ViewBag.currentUser = CustomRoleProvider.currentUser;
         return(View());
     }
     catch (ProviderIncompatibleException ex)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "No database connection!"));
     }
 }
Exemple #13
0
        public ActionResult SaveUserSettings(viewUser user)
        {
            viewUser getUser = CMSService.GetUser(user.UserId);

            if (getUser.RoleId != user.RoleId)
            {
                //remove

                var username = user.UserName;
                var allroles = rsac.GetAllRoles(applicationname);

                foreach (var role in allroles)
                {
                    if (rsac.IsUserInRole(applicationname, username, role) == 1)
                    {
                        rsac.RemoveUsersFromRoles(applicationname, username, role);
                    }
                }


                //add



                string AMRoleName = CMSService.GetRoles().Where(r => r.Id == user.RoleId).FirstOrDefault().Description;


                CustomRoleProvider crp = new CustomRoleProvider();


                string appName = ConfigurationManager.AppSettings["ApplicationName"];

                string un = user.UserName;

                rsac.AddUsersToRoles(appName, un, AMRoleName);
            }



            CMSService.SaveUserSettings(user);



            return(RedirectToAction("UserAdmin"));
        }
 public DataManager(ILoginsRepository logins, IAuthorsRepository authors,
                     IGenresRepository genres, IDateRepository dates,
                     IPlaysRepository plays,IOrdersRepository orders, 
                     IRepertoireRepository repertories, ICategoryRepository categories,
                     ICategoriesInfoRepository categoriesInfo, ICourierInfoRepository courierInfo,
                     PrimaryMembershipProvider provider, CustomRoleProvider roleProvider)
 {
     this.logins = logins;
     this.genres = genres;
     this.authors = authors;
     this.dates = dates;
     this.plays = plays;
     this.orders = orders;
     this.provider = provider;
     this.repertories = repertories;
     this.categories = categories;
     this.categoriesInfo = categoriesInfo;
     this.courierInfo = courierInfo;
     this.roleProvider = roleProvider;
 }
 public ActionResult Login(LogInModel viewModel, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         var provider = (CustomMembershipProvider)Membership.Provider;
         if (provider.ValidateUser(viewModel.Email, viewModel.Password))
         {
             FormsAuthentication.SetAuthCookie(viewModel.Email, viewModel.RememberMe);
             if (Url.IsLocalUrl(returnUrl))
             {
                 return(Redirect(returnUrl));
             }
             var roleProvider = new CustomRoleProvider();
             return(roleProvider.IsUserInRole(viewModel.Email, "User") ? RedirectToAction("GetMyFiles", "File")
                 : RedirectToAction("FindAllUsers", "Admin"));
         }
         ModelState.AddModelError("", "Incorrect email or password");
     }
     return(View(viewModel));
 }
Exemple #16
0
        public ActionResult ShowForm()
        {
            using (botEntities3 bd = new botEntities3())
            {
                bool con = false;
                //если это админ или обычный пользователь
                CustomRoleProvider l = new CustomRoleProvider();
                con = l.IsUserInRole(User.Identity.Name, "Admin");
                if (con)
                {
                    List <Form> mes = bd.Form.ToList();
                    return(View(mes));
                }

                else
                {
                    return(View("Index", "Home"));
                }
            }
        }
Exemple #17
0
        public ActionResult ShowSubscribers()
        {
            using (botEntities3 bd = new botEntities3())
            {
                bool con = false;
                //если это админ или обычный пользователь
                CustomRoleProvider l = new CustomRoleProvider();
                con = l.IsUserInRole(User.Identity.Name, "Users");
                if (!con)
                {
                    List <Sub> subcribers = bd.Sub.ToList();
                    return(View(subcribers));
                }

                else
                {
                    return(View("Index", "Home"));
                }
            }
        }
Exemple #18
0
        // GET: Header
        public ActionResult HeaderList()
        {
            string[] role;

            CustomRoleProvider userRole = new CustomRoleProvider();

            role = userRole.GetRolesForUser(User.Identity.Name);

            if (role.Length != 0 && "admin" == role[0])
            {
                ViewBag.onAdmin = true;
            }
            else
            {
                ViewBag.onAdmin = false;
            }

            var list = db.TCategories.ToList();

            return(PartialView("_HeaderList", list));
        }
        public void TestFindUsersInRoleQueryCount()
        {
            var roleProvider = new CustomRoleProvider();
            var queryCount   = new EntityFrameworkActivityLogger();

            using (var usersContext = new ApplicationDbContext())
                using (new WithInterception(queryCount))
                {
                    roleProvider.FindUsersInRole(usersContext, testRoleX.Name, "");

                    Assert.AreEqual(2, queryCount.TotalExecutedCount,
                                    "The query count for CustomRoleProvider::FindUsersInRole exceeded the expected number.");

                    queryCount.Reset();

                    roleProvider.FindUsersInRole(usersContext, testRoleX.Name, testUserA.UserName);

                    Assert.AreEqual(2, queryCount.TotalExecutedCount,
                                    "The query count for CustomRoleProvider::FindUsersInRole exceeded the expected number.");
                }
        }
        public void TestGetRolesForUserQueryCount()
        {
            var roleProvider = new CustomRoleProvider();
            var queryCount   = new EntityFrameworkActivityLogger();

            using (var usersContext = new ApplicationDbContext())
                using (new WithInterception(queryCount))
                {
                    roleProvider.GetRolesForUser(usersContext, testUserA.UserName);

                    // We expect 1 query to get the user, and 1 query to get the role names
                    Assert.AreEqual(2, queryCount.TotalExecutedCount,
                                    "The query count for CustomRoleProvider::GetRolesForUser exceeded the expected number.");

                    queryCount.Reset();

                    roleProvider.GetRolesForUser(usersContext, testUserB.UserName);

                    // The query count should be the same, regardless of the number of roles a user is a member of
                    Assert.AreEqual(2, queryCount.TotalExecutedCount,
                                    "The query count for CustomRoleProvider::GetRolesForUser exceeded the expected number.");
                }
        }
Exemple #21
0
        public ActionResult ReActivateUser(viewUser user)
        {
            CMSService.ReActivateUser(user);


            viewUser getUser = CMSService.GetUser(user.UserId);

            if (getUser != null)
            {
                string AMRoleName = CMSService.GetRoles().Where(r => r.Id == getUser.RoleId).FirstOrDefault().Description;


                CustomRoleProvider crp = new CustomRoleProvider();


                string appName = ConfigurationManager.AppSettings["ApplicationName"];

                string un = getUser.UserName;

                rsac.AddUsersToRoles(appName, un, AMRoleName);
            }

            return(RedirectToAction("UserAdmin"));
        }
 public AccountManagementImpl(SSOContext _db)
 {
     this._db      = _db;
     _roleProvider = new CustomRoleProvider(_db);
 }
Exemple #23
0
 public AccountServiceImplementation(SSOContext _db)
 {
     this._db = _db;
     var r = new CustomRoleProvider(_db);
 }
Exemple #24
0
 public ActionResult Administration()
 {
     CustomRoleProvider.UserValidation(unit);
     ViewBag.currentUser = CustomRoleProvider.currentUser;
     return(View());
 }
Exemple #25
0
        public ActionResult AShowShops()
        {
            CustomRoleProvider l = new CustomRoleProvider();
            bool con             = l.IsUserInRole(User.Identity.Name, "Admin");

            if (!con)
            {
                return(View("Index", "Home"));
            }

            using (botEntities3 bd = new botEntities3())
            {
                try {
                    List <ShopsModel> shops = new List <ShopsModel>();

                    List <Users>    users    = bd.Users.ToList();
                    List <Token>    tokens   = bd.Token.ToList();
                    List <Category> category = bd.Category.ToList();
                    List <Product>  product  = bd.Product.ToList();

                    List <Category> category_list = new List <Category>();
                    List <Product>  product_list  = new List <Product>();

                    foreach (Users temp_user in users)
                    {
                        string k = null;
                        try
                        {
                            k = temp_user.TelegramUser.Where(x => x.UserId == temp_user.Id).FirstOrDefault().BotChannel;
                        }
                        catch
                        {
                            if (k == null)
                            {
                                k = " ";
                            }
                        }
                        if (k == null)
                        {
                            k = " ";
                        }
                        string name        = temp_user.Email;
                        string nameShop    = k;
                        Token  temp_tokens = new Token();
                        for (int i = 0; i < tokens.Count; i++)
                        {
                            if (temp_user.Id == tokens.ElementAt(i).UserID)
                            {
                                temp_tokens = tokens.ElementAt(i);
                                break;
                            }
                        }
                        category_list = new List <Category>();
                        product_list  = new List <Product>();
                        foreach (Category temp_category in category)
                        {
                            if (temp_tokens.Id == temp_category.TokenId)
                            {
                                foreach (Product prod in product)
                                {
                                    if (prod.CategoryId == temp_category.CategoryId)
                                    {
                                        product_list.Add(prod);
                                    }
                                }
                            }
                        }

                        shops.Add(new ShopsModel(nameShop, name, product_list));
                    }
                    return(View(shops));
                }
                catch
                {
                }
                return(View());
            }
        }
 protected void FormView1_DataBound(object sender, EventArgs e)
 {
     CheckBoxList cbdataRoles = (CheckBoxList)FormView1.Row.FindControl("dataRoles");
     TextBox tbdataUserName = (TextBox)FormView1.Row.FindControl("dataUserName");
     CustomRoleProvider role = new CustomRoleProvider();
     string[] listRoles = role.GetAllRoles();
     cbdataRoles.Items.Clear();
     foreach (var item in listRoles)
     {
         cbdataRoles.Items.Add(item.ToString());
     }
 }
Exemple #27
0
        public static void CreateRole(string roleName)
        {
            CustomRoleProvider crp = new CustomRoleProvider();

            crp.CreateRole(roleName);
        }