Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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;
            }
        }