public async Task <User> GetUserAsync(Guid userid) { DocumentDBRepository <User> userRepo = new DocumentDBRepository <User>(); var userDetails = await userRepo.GetItemAsync(userid); if (userDetails == null) { return(null); } return(userDetails); }
public async Task <Event> UpdateContent(Guid event_guid, Guid announcement_guid, Guid content_id, Content content) { DocumentDBRepository <Event> eventRepo = new DocumentDBRepository <Event>(); ICollection <EventAggregateRoot> roots = new List <EventAggregateRoot>(); try { var event1 = await eventRepo.GetItemAsync(event_guid); List <Announcement> updated_announcement = new List <Announcement>(); foreach (var announcement in event1.Announcements) { if (announcement.Id == announcement_guid) { List <Content> updated_content = new List <Content>(); foreach (Content dbcontent in announcement.Content) { if (dbcontent.Id == content_id) { updated_content.Add(content); } else { updated_content.Add(dbcontent); } } updated_announcement.Add(new Announcement() { Content = updated_content, Description = announcement.Description, Id = announcement.Id, Img = announcement.Img, PostedDate = announcement.PostedDate, Title = announcement.Title }); } else { updated_announcement.Add(new Announcement() { Content = announcement.Content, Description = announcement.Description, Id = announcement.Id, Img = announcement.Img, PostedDate = announcement.PostedDate, Title = announcement.Title }); } } event1.Announcements = updated_announcement; var res = eventRepo.UpdateItemAsync(event_guid, event1); return(await res); } catch (Exception m) { Console.WriteLine(m.Message); return(null); } }
//TODO: From -> Lakhan : Check if the below implementation is right or not . Is there any unused code?? public async Task <Board> AddContent(Guid board_guid, Guid announcement_guid, Content content) { DocumentDBRepository <Board> boardRepo = new DocumentDBRepository <Board>(); try { var dbBoards = await boardRepo.GetItemAsync(board_guid); List <Announcement> updated_announcement = new List <Announcement>(); foreach (var announcement in dbBoards.Announcements) { if (announcement.Id == announcement_guid) { List <Content> updated_content = announcement.Content.Append(new Content() { Description = content.Description, Id = Guid.NewGuid(), Image = content.Image, IsActive = content.IsActive, IsApproved = content.IsApproved, Posted = DateTime.Now, PostedBy = content.PostedBy, Title = content.Title, DateCreatedOn = DateTime.UtcNow, DateModifiedOn = DateTime.UtcNow }).ToList(); updated_announcement.Add(new Announcement() { Content = updated_content, Description = announcement.Description, Id = announcement.Id, Img = announcement.Img, PostedDate = announcement.PostedDate, Title = announcement.Title, DateCreatedOn = announcement.DateCreatedOn, DateModifiedOn = DateTime.UtcNow }); } else { updated_announcement.Add(new Announcement() { Content = announcement.Content, Description = announcement.Description, Id = announcement.Id, Img = announcement.Img, PostedDate = announcement.PostedDate, Title = announcement.Title, DateCreatedOn = announcement.DateCreatedOn, DateModifiedOn = DateTime.UtcNow }); } } dbBoards.Announcements = updated_announcement; var res = boardRepo.UpdateItemAsync(board_guid, dbBoards); return(await res); } catch (Exception m) { Console.WriteLine(m.Message); throw; } }
public async Task <Event> AddAnnouncement(Guid eventid, Announcement announcement) { DocumentDBRepository <Event> eventRepo = new DocumentDBRepository <Event>(); Event event1 = await eventRepo.GetItemAsync(eventid); announcement.InitId(); event1.Announcements.Add(announcement); var result = await eventRepo.UpdateItemAsync(eventid, event1); return(result); }
public async Task <Event> UpdateEvent(Event @event) { DocumentDBRepository <Event> eventRepo = new DocumentDBRepository <Event>(); Event event1 = await eventRepo.GetItemAsync(@event.Id); event1.EventName = @event.EventName; event1.EventBanner = @event.EventBanner; event1.Description = @event.Description; event1.ShowAsBanner = @event.ShowAsBanner; Event updatedEvent = await eventRepo.UpdateItemAsync(event1.Id, event1); return(updatedEvent); }
public async Task <Board> AddAnnouncement(Guid boardid, Announcement announcement) { DocumentDBRepository <Board> boardRepo = new DocumentDBRepository <Board>(); Board board1 = await boardRepo.GetItemAsync(boardid); announcement.InitId(); announcement.DateCreatedOn = DateTime.UtcNow; announcement.DateModifiedOn = DateTime.UtcNow; board1.Announcements.Add(announcement); var result = await boardRepo.UpdateItemAsync(boardid, board1); return(result); }
public async Task <Event> AddContent(Guid event_guid, Guid announcement_guid, Content content) { DocumentDBRepository <Event> eventRepo = new DocumentDBRepository <Event>(); ICollection <EventAggregateRoot> roots = new List <EventAggregateRoot>(); try { var event1 = await eventRepo.GetItemAsync(event_guid); List <Announcement> updated_announcement = new List <Announcement>(); foreach (var announcement in event1.Announcements) { if (announcement.Id == announcement_guid) { List <Content> updated_content = announcement.Content.Append(new Content() { Description = content.Description, Id = Guid.NewGuid(), Image = content.Image, IsActive = content.IsActive, IsApproved = content.IsApproved, Posted = DateTime.Now, PostedBy = content.PostedBy, Title = content.Title }).ToList(); updated_announcement.Add(new Announcement() { Content = updated_content, Description = announcement.Description, Id = announcement.Id, Img = announcement.Img, PostedDate = announcement.PostedDate, Title = announcement.Title }); } else { updated_announcement.Add(new Announcement() { Content = announcement.Content, Description = announcement.Description, Id = announcement.Id, Img = announcement.Img, PostedDate = announcement.PostedDate, Title = announcement.Title }); } } event1.Announcements = updated_announcement; var res = eventRepo.UpdateItemAsync(event_guid, event1); return(await res); } catch (Exception m) { Console.WriteLine(m.Message); return(null); } }
public async Task <Board> UpdateBoard(Board board) { DocumentDBRepository <Board> boardRepo = new DocumentDBRepository <Board>(); Board dbBoard = await boardRepo.GetItemAsync(board.Id); dbBoard.BoardName = board.BoardName; dbBoard.BoardBanner = board.BoardBanner; dbBoard.Description = board.Description; dbBoard.ShowAsBanner = board.ShowAsBanner; dbBoard.DateModifiedOn = DateTime.UtcNow; dbBoard.DateSchedule = board.DateSchedule; dbBoard.IsFixed = board.IsFixed; dbBoard.Order = board.Order; Board updatedBoard = await boardRepo.UpdateItemAsync(dbBoard.Id, dbBoard); return(updatedBoard); }