public ActionResult Delete(int id) { if (!this.messagesService.MessageExists(id)) { throw new NonExistingMessageException(); } if (this.messagesService.UnauthorizedDelete(id, HttpContext.User.Identity.Name)) { throw new UnauthorizedDeleteException(); } InboxMessageViewModel messageVm = this.messagesService.GetInboxMessageById(id); return(this.View(messageVm)); }
public async Task InsertAsync(InboxMessageViewModel inboxMessageView) { try { var toUserProfile = await _context.UserProfiles.FirstOrDefaultAsync(a => a.Email == inboxMessageView.ToName); var fromUserProfile = await _context.UserProfiles.FirstOrDefaultAsync(a => a.Email == inboxMessageView.FromName); await InsertAsync(new InboxMessage() { ToUserProfileId = toUserProfile.Id, UserProfileId = fromUserProfile.Id, Content = inboxMessageView.Content, IsSee = false }); } catch (Exception) { throw; } }