Ejemplo n.º 1
0
        /// <summary>
        /// Returns person data prior to the modification.
        /// </summary>
        /// <returns>the person data object</returns>
        private tOsoby GetPersonData()
        {
            int?userId = service.GetClientId(User.Identity.Name);

            if (userId.HasValue)
            {
                tOsoby person = service.GetPersonData(userId.Value);
                return(person);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public static void AddUserToRole(String userName)
        {
            var service = new TravelAgencyService();
            int?userid  = service.GetClientId(userName);

            if (userid != null)
            {
                tOsoby person = service.GetPersonData(userid.Value);
                if (person != null)
                {
                    String roleName = person.bPracownik ? ADMIN_ROLE : CLIENT_ROLE;
                    if (!Roles.IsUserInRole(userName, roleName))
                    {
                        if (Roles.GetAllRoles().Where(r => r == roleName).FirstOrDefault() == null)
                        {
                            Roles.CreateRole(roleName);
                        }
                        Roles.AddUserToRole(userName, roleName);
                    }
                }
            }
        }