public ActionResult Create(MessageFormModel model) { var item = Mapper.Map <MessageFormModel, Message>(model); GetSession.Save(item); return(RedirectToAction("Index")); }
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")); }
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)); }
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))); }
public ActionResult Create() { var model = new MessageFormModel(); return(View(model)); }