public ActionResult EditSection(Section s, int ecologistID) { ViewBag.ecologists = GetEcologistsSurnames(ecologistID); //учитываем dropdown list var section = db.Sections.Find(s.SectionID); section.Ecologist = db.Ecologists.Find(ecologistID); TryUpdateModel<Section>(section); //расчет двух "столбцов" section.CalculateParticipantsCount(); section.CalculateFreeSpots(); db.Entry<Section>(section).State = System.Data.EntityState.Modified; db.SaveChanges(); return RedirectToAction("SystemSections"); }
public ActionResult CreateSection(Section s, int ecologistID) { ViewBag.ecologists = GetEcologistsSurnames(ecologistID); //Debug.WriteLine(ecologistID + " " + ecologistID.GetType()); try { s.Ecologist = db.Ecologists.Find(ecologistID); //s.CalculateParticipantsCount(); s.CalculateFreeSpots(); db.Sections.Add(s); db.SaveChanges(); return RedirectToAction("SystemSections"); } catch { return View(); } }