public ActionResult ShulView(int ShulID) { ShulViewModel model = new ShulViewModel(); model.ZVM = new ZmanimViewModel() { ShulID = ShulID }; model.Shul = db.Shuls.Find(ShulID); //model.Zmanim = model.Shul.Zmanim.ToList() ?? null; return(View(model)); }
public ActionResult AddZman(ShulViewModel model) { Shul shul = db.Shuls.Find(model.ZVM.ShulID); Zman zman = new Zman(); zman.Days = model.ZVM.Days; if (model.ZVM.Time != null) { zman.Time = model.ZVM.Time; } else { zman.OtherTime = model.ZVM.OtherTime; } zman.Prayer = model.ZVM.Prayer; shul.Zmanim.Add(zman); db.SaveChanges(); return(RedirectToAction("ShulView", new { model.ZVM.ShulID })); }