public void Init(string email, UserRepository repository) { if (!string.IsNullOrEmpty(email)) { User = repository.GetUser(email); User.LastActivity = DateTime.Now; repository.ForceSaveChanges(); } }
public string ManageFriend(Guid? id) { using (UserRepository repo = new UserRepository()) { User curUser = repo.GetUser(CurrentUser.Instance.Current.Id); if (Request.HttpMethod == "PUT") curUser.Friends.Add(repo.GetUser(id.Value)); else if (Request.HttpMethod == "DELETE") curUser.Friends.Remove(repo.GetUser(id.Value)); else { Response.StatusCode = 404; return ""; } repo.ForceSaveChanges(); return "success"; } }