Пример #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));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ServiceToClient servicetoclient = db.ServiceToClients.Find(id);

            db.ServiceToClients.Remove(servicetoclient);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public PartialViewResult ShowFeedbackForm(string key)
        {
            ServiceToClient someServiceToClient = db.ServiceToClients.Where(m => m.UniqueKey.ToLower() == key).Take(1).SingleOrDefault();
            IEnumerable <AllowedViolation> someAllowedViolations = someServiceToClient.ServiceType.AllowedViolations;

            ViewBag.ServiceToClient = someServiceToClient;
            return(PartialView(someAllowedViolations));
        }
        // GET: /ServiceToClient/Create
        public ActionResult Create()
        {
            ViewBag.WorkerId      = new SelectList(db.Workers, "Id", "AspNetUser.UserName");
            ViewBag.ServiceTypeId = new SelectList(db.ServiceTypes, "Id", "Name");
            ViewBag.ClientId      = new SelectList(db.AspNetUsers, "Id", "UserName");
            ServiceToClient model = new ServiceToClient {
                Value = 0
            };

            return(View(model));
        }
 public ActionResult Edit([Bind(Include = "Id,WorkerId,ServiceTypeId,Value,UniqueKey,ValueSet,IsCallbackAllowed,ClientFeedback,Assigned,Started,Finished,ClientId")] ServiceToClient servicetoclient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(servicetoclient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.WorkerId      = new SelectList(db.Workers, "Id", "AspNetUser.UserName", servicetoclient.WorkerId);
     ViewBag.ServiceTypeId = new SelectList(db.ServiceTypes, "Id", "Name", servicetoclient.ServiceTypeId);
     ViewBag.ClientId      = new SelectList(db.AspNetUsers, "Id", "UserName", servicetoclient.ClientId);
     return(View(servicetoclient));
 }
Пример #6
0
        public JsonResult SetValue(string ticketNumber, Int16 value)
        {
            ServiceToClient someServiceToClient = db.ServiceToClients.Where(m => m.UniqueKey == ticketNumber).Take(1).SingleOrDefault();

            if (someServiceToClient == null)
            {
                return(Json(false, JsonRequestBehavior.DenyGet));
            }
            someServiceToClient.Value           = value;
            someServiceToClient.ValueSet        = DateTime.Now;
            db.Entry(someServiceToClient).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(Json(true, JsonRequestBehavior.DenyGet));
        }
        // GET: /ServiceToClient/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServiceToClient servicetoclient = db.ServiceToClients.Find(id);

            if (servicetoclient == null)
            {
                return(HttpNotFound());
            }
            return(View(servicetoclient));
        }
Пример #8
0
        public JsonResult Delete(int id)
        {
            ServiceToClient someServiceToClient = db.ServiceToClients.Find(id);

            someServiceToClient.Value    = 0;
            someServiceToClient.ValueSet = null;

            List <FoundViolation> someFoundViolations = someServiceToClient.FoundViolations.ToList();

            foreach (FoundViolation item in someFoundViolations)
            {
                db.Entry(someFoundViolations).State = System.Data.Entity.EntityState.Deleted;
            }
            db.SaveChanges();
            return(Json(1, JsonRequestBehavior.DenyGet));
        }
        // GET: /ServiceToClient/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServiceToClient servicetoclient = db.ServiceToClients.Find(id);

            if (servicetoclient == null)
            {
                return(HttpNotFound());
            }
            ViewBag.WorkerId      = new SelectList(db.Workers, "Id", "AspNetUser.UserName", servicetoclient.WorkerId);
            ViewBag.ServiceTypeId = new SelectList(db.ServiceTypes, "Id", "Name", servicetoclient.ServiceTypeId);
            ViewBag.ClientId      = new SelectList(db.AspNetUsers, "Id", "UserName", servicetoclient.ClientId);
            return(View(servicetoclient));
        }