// edit user details public bool Edit(User user) { try { //var ctx = HttpContext.Current; //try //{ // if (ctx != null) // { // var currentData = ((List<User>)ctx.Cache[CacheKey]).ToList(); // User user_ = currentData.Find(p => p.user_id == user.user_id); // currentData.Remove(user_); // currentData.Add(user); // ctx.Cache[CacheKey] = currentData.ToArray(); // } //} //catch (Exception ex) //{ // Console.WriteLine(ex.ToString()); // return false; //} User v = db.Users.Find(user.user_id); db.Entry(v).CurrentValues.SetValues(user); db.SaveChanges(); return true; } catch (System.Data.DataException ex) { // Shud do some logging Console.WriteLine(ex.ToString()); return false; } }
public bool RegisterUser(User user) { return user_repository.SaveUser(user); }
public bool Edit(User edit_user) { return user_repository.Edit(edit_user); }
// insert a user (register to the application) public bool SaveUser(User user) { var ctx = HttpContext.Current; try { // add information to the cache //var currentData = ((List<User>)ctx.Cache[CacheKey]).ToList(); //currentData.Add(user); //ctx.Cache[CacheKey] = currentData.ToArray(); // add data to the database db.Users.Add(user); db.SaveChanges(); return true; } catch (Exception ex) { Console.WriteLine(ex.ToString()); return false; } }