예제 #1
0
        public ActionResult Create(MessageFormModel model)
        {
            var item = Mapper.Map <MessageFormModel, Message>(model);

            GetSession.Save(item);

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public async Task <IActionResult> SendMessage(MessageFormModel messageModel)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }
            var userId = this._userManager.GetUserId(User);

            await this.users.SendMessage(userId, messageModel.Content);

            TempData.AddSuccessMessage($"Successfully send message");
            return(RedirectToAction(nameof(Index), "Home"));
        }
예제 #3
0
        public ActionResult Edit(MessageFormModel model)
        {
            if (ModelState.IsValid)
            {
                var item = GetSession.Get <Message>(model.Id);

                Mapper.Map <MessageFormModel, Message>(model, item);

                GetSession.Update(item);

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
예제 #4
0
        public async Task <IActionResult> Send(MessageFormModel model)
        {
            var senderId = GetCurrentUserId();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var recipient = await this.userManager.FindByNameAsync(model.Recipient);

            if (recipient == null)
            {
                TempData["Error"] = "There is no such user. Please try again!";
                return(View(model));
            }

            await this.messages.SendAsync(model.Title, model.Content, senderId, recipient.Id, DateTime.UtcNow);

            return(RedirectToAction(nameof(Sent)));
        }
예제 #5
0
        public ActionResult Create()
        {
            var model = new MessageFormModel();

            return(View(model));
        }