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; }
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; }
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; }
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; }
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; }
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; }