public ActionResult AddOrUpdate(PeriodModel model) { if (!ModelState.IsValid) { return(View(model)); } var isCreated = model.Id == Guid.Empty; var period = new Periods(); if (!isCreated) { period = PeriodRepository.GetById(model.Id); } period.Begin = model.Begin; period.End = model.End; period.Years = YearRepository.GetById(model.YearId); if (isCreated) { PeriodRepository.Add(period); } PeriodRepository.Save(); return(Redirect(Url.Action("Get", "Period", new { id = period.Id }))); }
public void DeletePeriod() { Period toDelete = repo.GetUniq(p => p.Title == "Remaining"); Assert.IsNotNull(repo.GetUniq(p => p.Title == "Remaining")); repo.Delete(toDelete); repo.Save(); Assert.IsNull(repo.GetUniq(p => p.Title == "Remaining")); Assert.IsNull(ctx.PricePerPersonSet.FirstOrDefault(p => p.Title == "Prix adulte room1 reste de l'année")); }
public ActionResult Delete(Guid id) { PeriodRepository.Delete(id); PeriodRepository.Save(); return(Redirect(Url.Action("GetAll", "Period"))); }