public async Task <IActionResult> Info(int?id) { if (id == null) { NotFound(); } SendMessageFromUser message = _context.SendMessageFromUsers.FirstOrDefault(m => m.Id == id); if (message == null) { NotFound(); } await _context.SaveChangesAsync(); return(View(message)); }
public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } SendMessageFromUser msg = _context.SendMessageFromUsers.Find(id); if (msg == null) { return(NotFound()); } msg.IsDeleted = true; await _context.SaveChangesAsync(); return(Json("Deleted")); }
public async Task <IActionResult> SendMsg(SendMessageFromUser userMesssage) { if (ModelState.IsValid) { _context.SendMessageFromUsers.Add(userMesssage); await _context.SaveChangesAsync(); return(Json("Success!")); } string errors = ""; foreach (var item in ModelState.Values) { foreach (var error in item.Errors) { errors += error.ErrorMessage; } } return(Json(errors)); }