public async Task <IActionResult> Index(IndexViewModel viewModel) { if (ModelState.IsValid) { ShopMessageModel message = new ShopMessageModel(); message.Email = viewModel.Email; message.Message = viewModel.Message; message.Name = viewModel.Name; message.Topic = viewModel.Topic; message.Sent = DateTime.Now; message.UserId = "Annonymous"; message.TypeName = "Annonymous"; message.Checked = false; message.Resolved = false; _inboxRepository.AddMessage(message); return(RedirectToAction("Index")); } return(View(viewModel)); }
public async Task <IActionResult> CreateMessageUser(CreateMessageViewModel viewModel) { if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(HttpContext.User); ShopMessageModel message = new ShopMessageModel(); message.Checked = false; message.Message = viewModel.Message; message.Resolved = false; message.Sent = DateTime.Now; message.Topic = viewModel.Topic; message.Email = user.Email; message.Name = $"{user.FirstName} {user.LastName}"; message.UserId = user.Id; _inboxRepository.AddMessage(message); return(RedirectToAction("UserPage", "Account")); } return(View(viewModel)); }