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); }
private void GetPromotion(int?promotionId, out Promotion promotion) { if (promotionId == null) { promotion = PromotionServices.GetForeignPromotion(); } else { promotion = PromotionServices.GetPromotionById((int)promotionId); } }