private DAL.Class CheckingClass(Chemical ch, Organoleptic or) { if ((or.Scent20 <= 2 && or.Scent60 <= 2 && or.Flavor <= 2 && or.Chromaticity <= 20 && or.Turbidity <= 1.5 && or.Temperature >= 8 && or.Temperature <= 12) && (ch.Residue <= 1000 && ch.Ph <= 9 && ch.Ph >= 6 && ch.Rigidity <= 7 && ch.Chlorides <= 350 && ch.Sulphates <= 500 && ch.Iron <= 0.3 && ch.Marhan <= 0.1 && ch.Fluorine <= 1.5 && ch.Nitrates <= 45)) { return(DAL.Class.first); } else if ((or.Scent20 <= 2 && or.Scent60 <= 2 && or.Flavor <= 2 && or.Chromaticity <= 20 && or.Turbidity <= 3.5 && or.Temperature >= 8 && or.Temperature <= 12) && (ch.Residue <= 1500 && ch.Ph <= 9 && ch.Ph >= 6 && ch.Rigidity <= 10 && ch.Chlorides <= 350 && ch.Sulphates <= 500 && ch.Iron <= 10 && ch.Marhan <= 1.0 && ch.Fluorine <= 1.5 && ch.Nitrates <= 45)) { return(DAL.Class.second); } else if ((or.Scent20 <= 2 && or.Scent60 <= 2 && or.Flavor <= 2 && or.Chromaticity <= 50 && or.Turbidity <= 3.5 && or.Temperature >= 8 && or.Temperature <= 12) && (ch.Residue <= 1500 && ch.Ph <= 9 && ch.Ph >= 6 && ch.Rigidity <= 10 && ch.Chlorides <= 350 && ch.Sulphates <= 500 && ch.Iron <= 20 && ch.Marhan <= 2.0 && ch.Fluorine <= 5 && ch.Nitrates <= 45)) { return(DAL.Class.third); } else { return(DAL.Class.undrinkable); } }
private Organoleptic WaterIntakeModelToOrganoleptic(WaterIntakeModel wtmodel) { Organoleptic or = new Organoleptic() { Id = 100, Scent20 = wtmodel.Scent20, Scent60 = wtmodel.Scent60, Flavor = wtmodel.Flavor, Chromaticity = wtmodel.Chromaticity, Turbidity = wtmodel.Turbidity, Temperature = wtmodel.Temperature }; return(or); }
public ActionResult EditWaterIntake(int?id) { if (id == null) { return(HttpNotFound()); } WaterIntake wt = db.WaterIntakes.Find(id); if (wt == null) { return(HttpNotFound()); } Chemical ch = wt.Chemical; Organoleptic or = wt.Organoleptic; WaterIntakeModel wtmodel = new WaterIntakeModel() { Id = wt.Id, LaboratoryId = wt.LaboratoryId, IntakeDate = wt.IntakeDate, LaboratoryDate = wt.LaboratoryDate, WorkerName = wt.WorkerName, StationId = wt.StationId, Status = wt.Status, Residue = ch.Residue, Ph = ch.Ph, Rigidity = ch.Rigidity, Chlorides = ch.Chlorides, Sulphates = ch.Sulphates, Iron = ch.Iron, Marhan = ch.Marhan, Fluorine = ch.Fluorine, Nitrates = ch.Nitrates, Scent20 = or.Scent20, Scent60 = or.Scent60, Flavor = or.Flavor, Chromaticity = or.Chromaticity, Turbidity = or.Turbidity, Temperature = or.Temperature }; WaterIntakeViewBag(); return(View(wtmodel)); }
public ActionResult DeleteWaterIntakeConfirmed(int?id) { if (id == null) { return(HttpNotFound()); } WaterIntake wt = db.WaterIntakes.Find(id); if (wt == null) { return(HttpNotFound()); } Organoleptic or = db.Organoleptics.Find(id); Chemical ch = db.Chemicals.Find(id); db.Organoleptics.Remove(or); db.Chemicals.Remove(ch); db.WaterIntakes.Remove(wt); db.SaveChanges(); return(RedirectToAction("WaterIntakes")); }
public ActionResult EditWaterIntake(WaterIntakeModel wtmodel) { if (ModelState.IsValid) { WaterIntake wt = new WaterIntake() { Id = wtmodel.Id, LaboratoryId = wtmodel.LaboratoryId, IntakeDate = wtmodel.IntakeDate, LaboratoryDate = wtmodel.LaboratoryDate, WorkerName = wtmodel.WorkerName, StationId = wtmodel.StationId, }; Chemical ch = new Chemical() { Id = wtmodel.Id, Residue = wtmodel.Residue, Ph = wtmodel.Ph, Rigidity = wtmodel.Rigidity, Chlorides = wtmodel.Chlorides, Sulphates = wtmodel.Sulphates, Iron = wtmodel.Iron, Marhan = wtmodel.Marhan, Fluorine = wtmodel.Fluorine, Nitrates = wtmodel.Nitrates }; Organoleptic or = new Organoleptic() { Id = wtmodel.Id, Scent20 = wtmodel.Scent20, Scent60 = wtmodel.Scent60, Flavor = wtmodel.Flavor, Chromaticity = wtmodel.Chromaticity, Turbidity = wtmodel.Turbidity, Temperature = wtmodel.Temperature }; if (wtmodel.LaboratoryDate == null) { wt.Status = DAL.Status.taken; } else { wt.Status = DAL.Status.investigated; } db.Entry(wt).State = EntityState.Modified; db.Entry(ch).State = EntityState.Modified; db.Entry(or).State = EntityState.Modified; var k = db.WaterIntakes.OrderByDescending(a => a.Id).First(); Station s = db.Stations.Find(wtmodel.StationId); if (wtmodel.Id == k.Id) { s.Class = CheckingClass(ch, or); } db.Entry(s).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("WaterIntakes")); } WaterIntakeViewBag(); return(View(wtmodel)); }
public ActionResult CreateWaterIntake(WaterIntakeModel wtmodel) { Laboratory b = db.Laboratories.Find(wtmodel.LaboratoryId); Station s = db.Stations.Find(wtmodel.StationId); if (b == null) { throw new OperationCanceledException("Laboratory not found"); } if (s == null) { throw new OperationCanceledException("Station not found"); } WaterIntake wt = WaterIntakeModelToWaterIntakeMap(wtmodel); wt.Laboratory = b; wt.Station = s; Chemical ch = WaterIntakeModelToChemical(wtmodel); Organoleptic or = WaterIntakeModelToOrganoleptic(wtmodel); if (ModelState.IsValid) { if (wtmodel.LaboratoryDate == null) { wt.Status = DAL.Status.taken; } else { wt.Status = DAL.Status.investigated; } s.Class = CheckingClass(ch, or); db.WaterIntakes.Add(wt); db.Chemicals.Add(ch); db.Organoleptics.Add(or); db.SaveChanges(); return(RedirectToAction("WaterIntakes")); } else { WaterIntakeViewBag(); if (wtmodel.IntakeDate == default(DateTime)) { ViewBag.IntakeDate = DateTime.Now; } else { ViewBag.IntakeDate = wtmodel.IntakeDate; } if (wtmodel.LaboratoryDate == default(DateTime)) { ViewBag.LaboratoryDate = DateTime.Now; } else { ViewBag.LaboratoryDate = wtmodel.LaboratoryDate; } return(View(wtmodel)); } }