Esempio n. 1
0
        public JsonResult Submit(FormCollection form)
        {
            ServiceToClient someServiceToClient = db.ServiceToClients.Find(Convert.ToInt32(form["ServiceToClientId"]));

            if (someServiceToClient != null)
            {
                someServiceToClient.Value          = Convert.ToInt16(form["ClientValue"]);
                someServiceToClient.ValueSet       = DateTime.Now;
                someServiceToClient.ClientFeedback = form["CommentForViolation"];

                for (int i = 0; i < form.AllKeys.Count(); i++)
                {
                    if (form.AllKeys[i].IndexOf("violationType_") < 0)
                    {
                        continue;
                    }

                    int violationType = Convert.ToInt32(form.AllKeys[i].ToString().Replace("violationType_", ""));
                    if (db.FoundViolations.Where(m => m.ServiceToClientId == someServiceToClient.Id).Where(m => m.ViolationTypeId == violationType).Any() == false)
                    {
                        FoundViolation someFoundViolation = new FoundViolation {
                            ServiceToClientId = someServiceToClient.Id, ViolationTypeId = violationType
                        };
                        db.FoundViolations.Add(someFoundViolation);
                        db.SaveChanges();
                    }
                }

                db.SaveChanges();
                return(Json("1", JsonRequestBehavior.DenyGet));
            }

            return(Json("0", JsonRequestBehavior.DenyGet));
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(long id)
        {
            FoundViolation foundviolation = db.FoundViolations.Find(id);

            db.FoundViolations.Remove(foundviolation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "Id,ServiceToClientId,ViolationTypeId")] FoundViolation foundviolation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(foundviolation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ServiceToClientId = new SelectList(db.ServiceToClients, "Id", "UniqueKey", foundviolation.ServiceToClientId);
     ViewBag.ViolationTypeId   = new SelectList(db.ViolationTypes, "Id", "Name", foundviolation.ViolationTypeId);
     return(View(foundviolation));
 }
Esempio n. 4
0
        // GET: /FoundViolation/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FoundViolation foundviolation = db.FoundViolations.Find(id);

            if (foundviolation == null)
            {
                return(HttpNotFound());
            }
            return(View(foundviolation));
        }
Esempio n. 5
0
        // GET: /FoundViolation/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FoundViolation foundviolation = db.FoundViolations.Find(id);

            if (foundviolation == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ServiceToClientId = new SelectList(db.ServiceToClients, "Id", "UniqueKey", foundviolation.ServiceToClientId);
            ViewBag.ViolationTypeId   = new SelectList(db.ViolationTypes, "Id", "Name", foundviolation.ViolationTypeId);
            return(View(foundviolation));
        }