Esempio n. 1
0
 public ActionResult NewList(List list)
 {
     if (ModelState.IsValid)
     {
         userRepo.NewList(list);
         Redirect("/" + User.Identity.Name + "/lists");
     }
     ViewBag.Error = ModelState.Keys.SelectMany(key => ModelState[key].Errors).ToList();
     return Redirect("/" + User.Identity.Name + "/lists");
 }
Esempio n. 2
0
 public string ToJson(string username = "", List<Tweet> favorites = null)
 {
     favorites = favorites ?? new List<Tweet>();
     var serializer = new JavaScriptSerializer();
     return
         serializer.Serialize(
             new
                 {
                     Id = Id,
                     Message = Message,
                     SenderName = Sender.FullName,
                     SenderUserName = Sender.Username,
                     DateAndTime = ((DateAndTime.HasValue ? DateAndTime.Value : DateTime.Now) - new DateTime(1970, 1, 1)).TotalMilliseconds,
                     Url = "/" + Sender.Username + "/status/" + Id,
                     UserProfileUrl = "/" + Sender.Username,
                     IsFavorite = (favorites.Any(t => t.Id == Id)) ? "favorited" : "",
                     Avatar = Sender.GetAvatar("small"),
                     IsMine = String.Equals(Sender.Username, username, StringComparison.CurrentCultureIgnoreCase),
                 });
 }
Esempio n. 3
0
 public void NewList(List list)
 {
     list.User = GetCurrentUser();
     GetCurrentUser().Lists.Add(list);
     datacontext.SaveChanges();
 }