/*function used by javascript to get data about complains*/ public JsonResult getComplains(complain userComplain) { if (userComplain.mail.Length < 5 || userComplain.name.Length < 3 || userComplain.message.Length < 15) { return(Json(false, JsonRequestBehavior.AllowGet)); } try { userComplain.id = Guid.NewGuid(); userComplain.dateOfJoin = DateTime.Now; if (isUserAuthenticated()) { userComplain.general = true; } else { userComplain.general = false; } db.complains.Add(userComplain); db.SaveChanges(); return(Json(true, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public IHttpActionResult Putcomplain(int id, complain complain) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != complain.Id) { return(BadRequest()); } db.Entry(complain).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!complainExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { complain complain = db.complains.Find(id); db.complains.Remove(complain); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Complain_Id,ComplainTo,ComplainFrom,Complain_Subject,DescriptionMsg,Date,Customer_id")] complain complain) { if (ModelState.IsValid) { db.Entry(complain).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Customer_id = new SelectList(db.customers, "Customer_Id", "FirstName", complain.Customer_id); return(View(complain)); }
public IHttpActionResult Getcomplain(int id) { complain complain = db.complains.Find(id); if (complain == null) { return(NotFound()); } return(Ok(complain)); }
public IHttpActionResult Postcomplain(complain complain) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.complains.Add(complain); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = complain.Id }, complain)); }
// GET: complains/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } complain complain = db.complains.Find(id); if (complain == null) { return(HttpNotFound()); } return(View(complain)); }
public IHttpActionResult Deletecomplain(int id) { complain complain = db.complains.Find(id); if (complain == null) { return(NotFound()); } db.complains.Remove(complain); db.SaveChanges(); return(Ok(complain)); }
// GET: complains/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } complain complain = db.complains.Find(id); if (complain == null) { return(HttpNotFound()); } ViewBag.Customer_id = new SelectList(db.customers, "Customer_Id", "FirstName", complain.Customer_id); return(View(complain)); }
/*add new complain for users*/ public JsonResult contactUs(complain userComplain) { try {//no validation at server untill now userComplain.id = Guid.NewGuid(); userComplain.dateOfJoin = DateTime.Now; if (User.Identity.IsAuthenticated) { userComplain.general = true; } db.complains.Add(userComplain); db.SaveChanges(); } catch (Exception ex) { return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); }