Ejemplo n.º 1
0
        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 })));
        }
Ejemplo n.º 2
0
        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"));
        }
Ejemplo n.º 3
0
 public ActionResult Delete(Guid id)
 {
     PeriodRepository.Delete(id);
     PeriodRepository.Save();
     return(Redirect(Url.Action("GetAll", "Period")));
 }