Esempio n. 1
0
        public ListScreenDTO ListScreenCollectionDataDL(int listID, int personID)
        {
            try
            {
                using (var context = new MiniBirdEntities())
                {
                    var currentList = context.List.Find(listID);

                    var listScreenDTO = new ListScreenDTO();
                    listScreenDTO.CurrentListSection.MyListID     = currentList.ListID;
                    listScreenDTO.CurrentListSection.Name         = currentList.Name;
                    listScreenDTO.CurrentListSection.Description  = currentList.Description;
                    listScreenDTO.CurrentListSection.MembersCount = context.UserToList.Where(ul => ul.ID_List == currentList.ListID).Count();
                    listScreenDTO.CanEdit = (personID == currentList.ID_Person) ? true : false;

                    var myLists = context.List.Where(ml => ml.ID_Person == personID);

                    foreach (var list in myLists)
                    {
                        listScreenDTO.MyListsSection.Add(new ListDTO()
                        {
                            MyListID    = list.ListID,
                            Name        = list.Name,
                            Description = list.Description,
                            Privacy     = (list.IsPrivate != true) ? Privacy.Public : Privacy.Private
                        });
                    }

                    IQueryable <UserToList> personsInThisList = context.UserToList.Where(ul => ul.ID_List == currentList.ListID);

                    foreach (var personITL in personsInThisList)
                    {
                        var posts   = context.Post.Where(p => p.ID_Person == personITL.ID_Person).ToList();
                        var reposts = context.RePost.Where(rp => rp.ID_PersonThatRePost == personITL.ID_Person).ToList();

                        listScreenDTO.PostSection.AddRange(FillPostSection(posts, personID, reposts));
                    }

                    listScreenDTO.PostSection = listScreenDTO.PostSection.OrderByDescending(ps => ps.PublicationDate).ToList();

                    return(listScreenDTO);
                }
            }
            catch
            {
                throw;
            }
        }
Esempio n. 2
0
 public ActionResult RemoveList(ListScreenDTO model)
 {
     Account.RemoveListSL(model.CurrentListSection.MyListID, ActiveSession.GetPersonID());
     return(RedirectToAction("ProfileScreen", "Account", new { id = ActiveSession.GetPersonID(), v = "lists" }));
 }