public void SendToNotification(Message message) { try { //invoke sending to external service message.IsSent = true; _db.Entry(message).State = EntityState.Modified; _db.SaveChangesAsync(); } catch (Exception e) { message.IsSent = false; _db.Entry(message).State = EntityState.Modified; _db.SaveChangesAsync(); } }
public ActionResult Edit([Bind(Include = "ID,Text,Date,FromUser,ToUser")] Message message) { if (ModelState.IsValid) { db.Entry(message).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(message)); }