public ActionResult Edit(RateSystemViewModel model) { if (!ModelState.IsValid || model == null) { return this.View(model); } if (model.StarDateTime >= model.EndDateTime) { this.ModelState.AddModelError(string.Empty, "Start date can not be greater than end date."); return this.View(model); } var rateSystemDb = this.rateSystems.GetById(model.Id); if (rateSystemDb == null) { this.ModelState.AddModelError(string.Empty, "The rate system is not found"); return this.View(model); } rateSystemDb.RateSystemName = model.RateSystemName; rateSystemDb.StarDateTime = model.StarDateTime; rateSystemDb.EndDateTime = model.EndDateTime; this.rateSystems.Update(rateSystemDb); return this.RedirectToAction<RateSystemController>(c => c.Index()); }
public ActionResult Create(RateSystemViewModel model) { if (!ModelState.IsValid || model == null) { return this.View(model); } if (model.StarDateTime >= model.EndDateTime) { this.ModelState.AddModelError(string.Empty, "Началната дата не може да е по голяма от крайната дата."); return this.View(model); } var modelDb = this.Mapper.Map<RateSystem>(model); this.rateSystems.Add(modelDb); return this.RedirectToAction<RateSystemController>(c => c.Index()); }