コード例 #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);
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int?id      = service.GetClientId(User.Identity.Name);
            int?offerId = GetOfferId();
            int count   = 0;

            if (id.HasValue && offerId.HasValue)
            {
                count = service.GetAttractionHistoryList(id.Value, offerId.Value).Count();
                AttractionPanel.Visible = count > 0;
            }
        }
コード例 #3
0
 public static int?GetUserId(TravelAgencyService service, IPrincipal user)
 {
     if (user.Identity.IsAuthenticated)
     {
         return(service.GetClientId(user.Identity.Name));
     }
     return(null);
 }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (User.Identity.IsAuthenticated)
     {
         TravelAgencyService service = new TravelAgencyService();
         using (service.ToDisposable())
         {
             offerIdToReservedMap = service.GetOfferIdToReservedMap(service.GetClientId(User.Identity.Name));
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// Returns Client ID for the logged user.
 /// </summary>
 /// <param name="user">the logged user</param>
 /// <returns>the Client ID or null when it is not found</returns>
 public static int?GetLoggerClientID(IPrincipal user)
 {
     if (user.Identity.IsAuthenticated)
     {
         TravelAgencyService service = new TravelAgencyService();
         using (service.ToDisposable())
         {
             int?userId = service.GetClientId(user.Identity.Name);
             return(userId);
         }
     }
     return(null);
 }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int?offerId = GetOfferId();

            if (offerId.HasValue)
            {
                int attractionCount = service.GetAttractions(offerId.Value).Count();
                AttractionPanel.Visible = attractionCount > 0;
            }
            if (User.Identity.IsAuthenticated)
            {
                attractionIdToReservedMap = service.GetAttractionIdToReservedMap(service.GetClientId(User.Identity.Name));
            }
        }
コード例 #7
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);
                    }
                }
            }
        }
コード例 #8
0
        private bool IsAttractionReserved(int attractionId)
        {
            int?clientId = service.GetClientId(User.Identity.Name);

            return(service.IsAttractionReserved(attractionId, clientId));
        }