public ActionResult AddPerson(int?add) { IEnumerable <RequestContactList> req = from s in db.RequestContactList where s.OwnerId == userid && s.ContactId == (int)add select s; try { if (req.First() == null && add != null) { TempData["requestmessage"] = "You have already sent request. "; return(Redirect(Request.Url.ToString())); } } catch { using (DiabetEntities db = new DiabetEntities()) { RequestContactList newrequest = new RequestContactList(); newrequest.OwnerId = (int)userid; newrequest.status = 0; newrequest.ContactId = (int)add; db.RequestContactList.Add(newrequest); db.SaveChanges(); return(Redirect(Request.UrlReferrer.ToString())); } } return(Redirect(Request.UrlReferrer.ToString())); }
public ActionResult AcceptRequest(int?acceptid) { if (acceptid == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RequestContactList contact = db.RequestContactList.Find(acceptid); if (contact == null) { return(HttpNotFound()); } contact.status = 1; db.SaveChanges(); return(Redirect(Request.UrlReferrer.ToString())); }