public void MakeMovingTaskFromOffer([FromBody] dynamic json) { dynamic temp = JsonConvert.DeserializeObject(json.ToString()); int movingID = temp.ID; Moving tempMoving = (Moving)database.Tasks.Where(i => i.Offer.ID == movingID).Include(o => o.Offer).Include(i => i.InspectionReport).Single(); Offer tempOffer = database.Offers.FirstOrDefault(o => o.ID == tempMoving.Offer.ID); tempMoving = PopulateMovingTask(temp, tempMoving); //int inspectionID = temp.InspectionReportID; //tempMoving.InspectionReport = database.Inspections.FirstOrDefault(i => i.ID == inspectionID); //Offer offer = database.Offers.FirstOrDefault(o => o.ID == offerID); //tempMoving.Offer = offer; InspectionReport inspection = new InspectionReport(); if (tempMoving.Offer.WasInspection == true) { tempMoving.WasInspection = true; inspection = database.Inspections.FirstOrDefault(i => i.ID == tempMoving.InspectionReport.ID); tempMoving.InspectionReport = inspection; } else { tempMoving.WasInspection = false; } tempMoving.WasOffer = true; database.Tasks.Update(tempMoving); database.SaveChanges(); }
public void EditDeliveryTask([FromBody] dynamic json) { dynamic temp = JsonConvert.DeserializeObject(json.ToString()); int deliveryID = temp.ID; Delivery delivery = PopulateDeliveryTask(temp); Delivery tempDelivery = (Delivery)database.Tasks.FirstOrDefault(i => i.ID == deliveryID); Offer tempOffer = new Offer(); if (tempDelivery.Offer != null) { tempOffer = database.Offers.FirstOrDefault(o => o.ID == tempDelivery.Offer.ID); delivery.Offer = tempOffer; } InspectionReport inspection = new InspectionReport(); if (tempDelivery.InspectionReport != null) { inspection = database.Inspections.FirstOrDefault(i => i.ID == tempDelivery.InspectionReport.ID); delivery.InspectionReport = inspection; } tempDelivery = delivery; tempDelivery.ID = deliveryID; database.Update(tempDelivery); database.SaveChanges(); }
public void EditMovingTask([FromBody] dynamic json) { dynamic temp = JsonConvert.DeserializeObject(json.ToString()); int movingID = temp.ID; Moving tempMoving = (Moving)database.Tasks.FirstOrDefault(i => i.ID == movingID); Moving moving = PopulateMovingTask(temp, tempMoving); InspectionReport tempInspection = new InspectionReport(); Offer tempOffer = new Offer(); if (tempMoving.Offer != null) { tempOffer = database.Offers.FirstOrDefault(o => o.ID == tempMoving.Offer.ID); moving.Offer = tempOffer; } if (tempMoving.InspectionReport != null) { tempInspection = database.Inspections.FirstOrDefault(i => i.ID == tempMoving.InspectionReport.ID); moving.InspectionReport = tempInspection; } tempMoving = moving; tempMoving.ID = movingID; database.Update(tempMoving); database.SaveChanges(); }
public string GetInspectionReport(int id) { InspectionReport tempReport = database.Inspections.Where(i => i.ID == id) .Include(e => e.Employee).Include(c => c.Car).Include(c => c.Customer).ThenInclude(c => c.ContactInfo) .Include(s => s.StartingAddress).Include(d => d.Destination).Single(); return(JsonConvert.SerializeObject(tempReport)); }
public void EditInspectionReport([FromBody] dynamic json) { dynamic temp = JsonConvert.DeserializeObject(json.ToString()); int inspectionID = temp.ID; InspectionReport inspectionReport = PopulateInspectionReport(temp); inspectionReport.ID = inspectionID; database.Inspections.Update(inspectionReport); database.SaveChanges(); }
public void MakeInspectionReport([FromBody] dynamic json) { dynamic temp = JsonConvert.DeserializeObject(json.ToString()); InspectionReport inspectionReport = PopulateInspectionReport(temp); Moving tempmoving = new Moving(); tempmoving.Phase = 1; tempmoving.InspectionReport = inspectionReport; database.Tasks.Add(tempmoving); database.SaveChanges(); }
public void MakeMovingTaskFromInspectionReport([FromBody] dynamic json) { dynamic temp = JsonConvert.DeserializeObject(json.ToString()); int inspectionID = temp.ID; Moving tempMoving = (Moving)database.Tasks.FirstOrDefault(i => i.InspectionReport.ID == inspectionID); Moving moving = PopulateMovingTask(temp, tempMoving); tempMoving = moving; tempMoving.Phase = 3; InspectionReport tempInspection = database.Inspections.FirstOrDefault(i => i.ID == inspectionID); tempMoving.InspectionReport = tempInspection; //int inspectionID = temp.InspectionReportID; //tempMoving.InspectionReport = database.Inspections.FirstOrDefault(i => i.ID == inspectionID); tempMoving.WasInspection = true; tempMoving.WasOffer = false; database.Tasks.Update(tempMoving); database.SaveChanges(); }