public JsonResult Add(CreateInspectionAreaItemRequest request)
        {
            if (request.InspectionAreaItemID <= 0)
            {
                InspectionAreaItem inspectionAreaItem = new InspectionAreaItem();
                inspectionAreaItem.InspectionAreaItemID = request.InspectionAreaItemID;
                inspectionAreaItem.ItemCondition = request.ItemCondition;
                inspectionAreaItem.ItemDescription = request.ItemDescription;
                inspectionAreaItem.ItemID = request.ItemID;
                inspectionAreaItem.ItemRepair = request.ItemRepair;


                db.InspectionAreaItems.Add(inspectionAreaItem);
                db.SaveChanges();
            }
            else
            {
                InspectionAreaItem inspectionAreaItem = db.InspectionAreaItems.Where(x => x.InspectionAreaItemID == request.InspectionAreaItemID).FirstOrDefault();
                if (inspectionAreaItem != null)
                {
                    inspectionAreaItem.InspectionAreaItemID = request.InspectionAreaItemID;
                    inspectionAreaItem.ItemCondition = request.ItemCondition;
                    inspectionAreaItem.ItemDescription = request.ItemDescription;
                    inspectionAreaItem.ItemID = request.ItemID;
                    inspectionAreaItem.ItemRepair = request.ItemRepair;

                    db.SaveChanges();
                }

            }

            return Json("true");
        }
        public JsonResult SubmitPart(List<InspectionPart> Data, string Signature)
        {
            CreateInspectionAreaItemRequest request = new CreateInspectionAreaItemRequest();
            request.ItemRepair = "n";
            foreach (var item in Data)
            {
                if (item.name == "areaID")
                    request.AreaID = int.Parse(item.value);
                else if (item.name == "condition")
                    request.ItemCondition = item.value.Substring(3);
                else if (item.name == "repair-needed")
                    request.ItemRepair = "y";
                else if (item.name == "inspectionAreaItemID")
                    request.InspectionAreaItemID = int.Parse(item.value);
            }

            var response = ApiWrapper.Post<CreateInspectionAreaItemRequest>("api/inspection/editPart", request);

            return response!=null?Json(new { success = true, responseText= "Successfuly sent the information!"}, JsonRequestBehavior.AllowGet): Json(new { success = false, responseText = "Failed to send the information!" }, JsonRequestBehavior.AllowGet);
        }
 public JsonResult editPart(CreateInspectionAreaItemRequest request)
 {
     InspectionAreaItem item = db.InspectionAreaItems.Where(x => x.InspectionAreaItemID == request.InspectionAreaItemID).FirstOrDefault();
     item.ItemCondition = request.ItemCondition;
     item.ItemRepair = request.ItemRepair;
     db.SaveChanges();
     return Json(item, JsonRequestBehavior.AllowGet);
 }