public async Task <ActionResult> Add([FromBody] InboxAddRequest request) { LoggedUser loggedUser = LoggedUser; try { await UnitOfWork.ExecuteTransactionAsync(async (transaction, timeout) => { Inbox inbox = new Inbox { Name = request.Name, AdminId = loggedUser.UserId, Active = true }; UnitOfWork.InboxRepository.Add(inbox); await UnitOfWork.SaveChangesAsync(); InboxUser inboxUser = new InboxUser { UserId = loggedUser.UserId, InboxId = inbox.Id }; UnitOfWork.InboxUserRepository.Add(inboxUser); await UnitOfWork.SaveChangesAsync(); }, null, null); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex.InnerExceptionMessage())); } }
public async Task <ActionResult> Seen(int inboxId) { LoggedUser loggedUser = LoggedUser; try { InboxUser inboxUser = await UnitOfWork.InboxUserRepository.GetByUserIdAndInboxIdAsync(loggedUser.UserId, inboxId); inboxUser.SeenDateTime = DateTime.Now; UnitOfWork.InboxUserRepository.Update(inboxUser); await UnitOfWork.SaveChangesAsync(); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex.InnerExceptionMessage())); } }