/*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));
     }
 }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            complain complain = db.complains.Find(id);

            db.complains.Remove(complain);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #4
0
 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));
 }
Beispiel #5
0
        public IHttpActionResult Getcomplain(int id)
        {
            complain complain = db.complains.Find(id);

            if (complain == null)
            {
                return(NotFound());
            }

            return(Ok(complain));
        }
Beispiel #6
0
        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));
        }
Beispiel #7
0
        // 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));
        }
Beispiel #8
0
        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));
        }
Beispiel #9
0
        // 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));
 }