public ActionResult AddInstitution(UpsertViewModel model) { ModelState["File"].Errors.Clear(); if (institutionRepository.Exists(model.Name)) ModelState.AddModelError("Name", $"There is already an institution with the name \"{model.Name}\"."); if (institutionRepository.DomainExists(model.ShortName)) ModelState.AddModelError("ShortName", $"There is already an institution with the domain \"{model.ShortName}\"."); if (!ModelState.IsValid) return View(model); institutionRepository.InsertOrUpdate(model.ToInstitution()); institutionRepository.Save(); return View("AddedInstitution", new InstitutionsAddedViewModel { AmountImported = 1 }); }
public ActionResult EditInstitution(UpsertViewModel model) { if (string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.ShortName)) return View(model); institutionRepository.InsertOrUpdate(model.ToInstitution()); institutionRepository.Save(); return RedirectToAction("Index", "Institutions"); }