示例#1
0
 public User Convert(C_User cUser)
 {
     User user = new User();
     user.Id = cUser.id;
     user.Username = cUser.username;
     user.Email = cUser.email;
     user.Password = cUser.password;
     user.Timestamp = cUser.timestamp;
     return user;
 }
示例#2
0
 public C_User Convert(User user)
 {
     C_User cuser = new C_User();
     cuser.id = user.Id;
     cuser.username = user.Username;
     cuser.email = user.Email;
     cuser.password = user.Password;
     cuser.timestamp = cuser.timestamp;
     return cuser;
 }
示例#3
0
        public List<Order> FindOrdersByUser(User user)
        {
            using (var context = Config.context)
            {
                try
                {
                    var data = context.C_Order.Select(i => i.C_User.id == user.Id);
                    List<Order> orders = new List<Order>();

                    return orders;

                }
                catch (Exception ex)
                {
                    // log here
                }
            }
            return null;
        }
示例#4
0
 public bool Edit(User user)
 {
     bool completed = false;
     using (var context = Config.context)
     {
         try
         {
             var item = context.C_User.Single(i => i.id == user.Id);
             item.id = user.Id;
             item.username = user.Username;
             item.email = user.Email;
             context.SaveChanges();
             completed = true;
         }
         catch (Exception ex)
         {
             // log here
         }
     }
     return completed;
 }
示例#5
0
 public bool Insert(User user)
 {
     bool completed = false;
     using (var context = Config.context)
     {
         try
         {
             user.Password = Config.GeneratePassword(user.Password);
             var data = context.C_User.Add(Convert(user));
             context.SaveChanges();
             completed =  true;
         }
         catch (Exception ex)
         {
             // log here
         }
     }
     return completed;
 }
示例#6
0
 public bool Remove(User user)
 {
     bool completed = false;
     using (var context = Config.context)
     {
         try
         {
             var item = context.C_User.Single(i => i.id == user.Id);
             var data = context.C_User.Remove(item);
             completed = true;
         }
         catch (Exception ex)
         {
             // log here
         }
     }
     return completed;
 }