Пример #1
0
        public User CreateUser(UserCreationDeserializer userDsl)
        {
            int phone;

            int.TryParse(userDsl.PhoneNumber, out phone);
            var promotion = PromotionServices.GetForeignPromotion();

            Role role;

            GetRole(null, out role);

            string password;

            GeneratePasswordSha256(userDsl.Password, out password);

            User user = Context.User.Add(new User()
            {
                FirstName   = userDsl.FirstName,
                LastName    = userDsl.LastName,
                Email       = userDsl.Email,
                Password    = password,
                PhoneNumber = phone,
                Promotion   = promotion,
                DateOfBirth = userDsl.DateOfBirth,
                Role        = role,
                Location    = userDsl.Location
            }).Entity;

            Context.SaveChanges();
            return(user);
        }
Пример #2
0
 private void GetPromotion(int?promotionId, out Promotion promotion)
 {
     if (promotionId == null)
     {
         promotion = PromotionServices.GetForeignPromotion();
     }
     else
     {
         promotion = PromotionServices.GetPromotionById((int)promotionId);
     }
 }
Пример #3
0
 private void GetPromotion(string promotionName, out Promotion promotion)
 {
     promotion = PromotionServices.GetPromotionByName(promotionName);
 }