示例#1
0
 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";
     }
 }
示例#2
0
 public void Init(string email, UserRepository repository)
 {
     if (!string.IsNullOrEmpty(email))
     {
         User = repository.GetUser(email);
         User.LastActivity = DateTime.Now;
         repository.ForceSaveChanges();
     }
 }
示例#3
0
        public ActionResult Index(Guid? profileId)
        {
            if (profileId.HasValue)
            {
                UserRepository repo = new UserRepository();
                User user = repo.GetUser(profileId.Value);

                if (user != null)
                    return View(user);
            }

            //todo: add proper error message (Profile not found)
            Response.StatusCode = 404;
            return new EmptyResult();
        }