Beispiel #1
0
        public Timeline UpdateTimeline(TimelineDTO timelineDto)
        {
            var timeline = _timelineRepository.GetById(timelineDto.TimelineId);

            if (timeline == null)
            {
                return(null);
            }

            var updatedTimeline = _mapper.Map(timelineDto, timeline);

            return(_timelineRepository.SaveChanges()
                ? updatedTimeline
                : throw new ArgumentException("Unexpected error saving entity"));
        }
Beispiel #2
0
        public TimelineDTO TimelineCollectionDataDL(int personID)
        {
            try
            {
                using (var context = new MiniBirdEntities())
                {
                    var person  = context.Person.Find(personID);
                    var posts   = context.Post.Where(ps => ps.ID_Person == personID && ps.InReplyTo == null).ToList();
                    var reposts = context.RePost.Where(rp => rp.ID_PersonThatRePost == person.PersonID).ToList();

                    var timelineDTO = new TimelineDTO();
                    timelineDTO.ProfileSection.PersonID       = person.PersonID;
                    timelineDTO.ProfileSection.UserName       = person.UserName;
                    timelineDTO.ProfileSection.NickName       = person.NickName;
                    timelineDTO.ProfileSection.ProfileHeader  = (person.ProfileHeader != null) ? ByteArrayToBase64(person.ProfileHeader, person.ProfileHeader_MimeType) : defaultHeader;
                    timelineDTO.ProfileSection.ProfileAvatar  = (person.ProfileAvatar != null) ? ByteArrayToBase64(person.ProfileAvatar, person.ProfileAvatar_MimeType) : defaultAvatar;
                    timelineDTO.ProfileSection.PostCount      = posts.Count();
                    timelineDTO.ProfileSection.FollowingCount = GetFollowingCount(context.Follow, person.PersonID);
                    timelineDTO.ProfileSection.FollowerCount  = GetFollowersCount(context.Follow, person.PersonID);
                    timelineDTO.TopTrendingsSection           = TopTrendings();

                    timelineDTO.PostSection.AddRange(FillPostSection(posts, person.PersonID, reposts));

                    var myFollowings = context.Follow.Where(f => f.ID_Person == personID);

                    foreach (var follow in myFollowings)
                    {
                        var personFollowedID   = context.Person.Find(follow.ID_PersonFollowed).PersonID;
                        var postsOfFollowing   = context.Post.Where(ps => ps.ID_Person == personFollowedID && ps.InReplyTo == null).ToList();
                        var repostsOfFollowing = context.RePost.Where(rp => rp.ID_PersonThatRePost == personFollowedID).ToList();

                        timelineDTO.PostSection.AddRange(FillPostSection(postsOfFollowing, person.PersonID, repostsOfFollowing));
                    }

                    timelineDTO.PostSection = timelineDTO.PostSection.OrderByDescending(ps => ps.PublicationDate).ToList();
                    return(timelineDTO);
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #3
0
 public ActionResult <List <TimelineDTO> > GetTimelineObjectsForCompany(int companyId)
 {
     return(Ok(_companyService.GetTimelineObjectsForCompany(companyId).Select(x => TimelineDTO.Of(x)).ToList()));
 }
Beispiel #4
0
 public ActionResult <TimelineDTO> AddContactTimeline([FromBody] Timeline timeline)
 {
     return(Ok(TimelineDTO.Of(_timelineService.AddTimelineObject(timeline))));
 }
Beispiel #5
0
 public ActionResult <TimelineDTO> DeleteContactTimeline(int id)
 {
     return(Ok(TimelineDTO.Of(_timelineService.DeleteTimelineObject(id))));
 }
Beispiel #6
0
 public ActionResult <TimelineDTO> GetTimelinePerId(int id)
 {
     return(Ok(TimelineDTO.Of(_timelineService.GetTimelineObject(id))));
 }
 public ActionResult <List <TimelineDTO> > DeleteTimelineFromContact(int contactId)
 {
     return(Ok(_contactService.GetTimelineObjectsForContact(contactId).Select(x => TimelineDTO.Of(x)).ToList()));
 }