public void AddNewUser(User user)
 {
     using (var context = new ShoppingWebDBEntities())
     {
         context.AddToUsers(user);
         context.SaveChanges();
     }
 }
        public void AddNewUser(User user)
        {
            if (_users.SingleOrDefault(u => u.UserName == user.UserName) != null)
                throw new UpdateException("Duplicate UserName");

            var newId = _users.Max(u => u.UserId) + 1;
            user.UserId = newId;
            _users.Add(user);
        }
Beispiel #3
0
 public void CalculateOrder(User user, CartModel cart)
 {
     decimal discount = (decimal) (user.Point > 200
                                    ? 0.15
                                    : user.Point >= 100
                                          ? 0.1
                                          : user.Point > 50
                                                ? 0.05
                                                : 0);
     cart.Total = cart.SubTotal*(1 - discount);
 }
 public void CalculateOrderTest(string message, User user, CartModel cart, decimal expectedResult)
 {
     _cartService.CalculateOrder(user, cart);
     Assert.AreEqual(expectedResult, cart.Total, message);
 }
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="point">Initial value of the Point property.</param>
 public static User CreateUser(global::System.Int32 userId, global::System.String userName, global::System.String password, global::System.Int32 point)
 {
     User user = new User();
     user.UserId = userId;
     user.UserName = userName;
     user.Password = password;
     user.Point = point;
     return user;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }