Пример #1
0
        public JsonResult Add(CreateInspectionRequest request)
        {
            Inspection inspection = new Inspection()
            {
                PropertyID = request.PropertyID,
                OverallComments = "Test on " + DateTime.Now.ToShortTimeString()
            };

            db.Inspections.Add(inspection);
            db.SaveChanges();

            var propertyAreas = db.Areas.Where(x => x.PropertyID == request.PropertyID).ToList();

            foreach (var propertyArea in propertyAreas)
            {
                InspectionArea area = new InspectionArea()
                {
                    InspectionID = inspection.InspectionID,
                    AreaID = propertyArea.AreaID
                };

                db.InspectionAreas.Add(area);
                db.SaveChanges();

                var areaItems = db.AreaItems.Where(x => x.AreaID == propertyArea.AreaID).ToList();

                foreach (var areaItem in areaItems)
                {
                    InspectionAreaItem item = new InspectionAreaItem()
                    {
                        InspectionAreaID = area.InspectionAreaID,
                        ItemID = areaItem.AreaItemID,
                        ItemDescription = areaItem.RoomItem,
                    };

                    db.InspectionAreaItems.Add(item);
                    db.SaveChanges();
                }
                
            }

            InspectionResponse response = new InspectionResponse();
            response.InspectionID = inspection.InspectionID;
            response.Completed = false;
            return Json(response);
        }
Пример #2
0
        public ActionResult ConfirmDetails(string inspectiontype, string latitude,string longitude,int propertyID, int tenantID, int ownerID)
        {
            CreateInspectionRequest request = new CreateInspectionRequest()
            {
                Latitude = latitude,
                Longitude = longitude,
                OwnerID = ownerID,
                PropertyID = propertyID,
                TenantID = tenantID
            };

            var response = ApiWrapper.Post<InspectionResponse>("api/inspection/add", request);
                
            return Redirect("/inspection/"+response.InspectionID+"/0");
        }