public string InsertNotification(int Id, int jobID, int appId, string message, string status) { var notify = db.Notifications.Where(n => n.ServiceId.Equals(Id)).FirstOrDefault(); if (notify != null) { //do nothing return("not successful. record duplicate"); } else { //insert notifications db.Notifications.Add(new Notifications { ServiceId = Id, JobId = jobID, AppId = appId, //Recipient = recipient, Message = message, //SendDT = sendDt, Status = status }); db.SaveChanges(); return("successful"); } }
public ActionResult Create([Bind(Include = "Id,ServiceId,JobId,AppId,Recipient,Message,SendDT,Status")] Notifications notifications) { if (ModelState.IsValid) { db.Notifications.Add(notifications); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(notifications)); }
public string updateRecord(int serviceId) { using (ChatServerModelContainer context = new ChatServerModelContainer()) { // "id" is the id in your table (parameter passed) Notifications jnr = context.Notifications.Where(n => n.ServiceId.Equals(serviceId)).FirstOrDefault(); jnr.Status = "Sent"; context.Entry(jnr).State = EntityState.Modified; context.SaveChanges(); return("Sent"); } }