public ActionResult Edit(MvcUniJudje.WebReference.AdminDTO admin) { if (admin.Login == null) { ModelState.AddModelError("Create", "Введите логин."); } if (admin.email == null) { ModelState.AddModelError("Create", "Введите Email."); } if (ModelState.IsValid) { using (var client = new MvcUniJudje.WebReference.ServiceForAdmin()) { try { client.WebUpdateAdmin(Session["session_key"].ToString(), admin, admin.ID, true, admin.NotifyNewRegistrations, true, admin.AllowAccessToAdminPanel, true); } catch (Exception ex) { ModelState.AddModelError("Create", ex.Message); } return(RedirectToAction("Index")); } } return(View(admin)); }
public ActionResult Create(MvcUniJudje.WebReference.AdminDTO admin) { if (admin.Login == null) { ModelState.AddModelError("LoginAdmin", "Введите логин."); } if (admin.email == null) { ModelState.AddModelError("EmailAdmin", "Введите Email."); } if (ModelState.IsValid) { using (var client = new MvcUniJudje.WebReference.ServiceForAdmin()) { try { admin.ID = client.CreateAdmin(Session["session_key"].ToString()).ID; client.WebUpdateAdmin(Session["session_key"].ToString(), admin, admin.ID, true, admin.NotifyNewRegistrations, true, admin.AllowAccessToAdminPanel, true); } catch (Exception ex) { switch (ex.Message) { case "Login already exist": ModelState.AddModelError("submit", "Логин уже существует"); break; default: ModelState.AddModelError("Create", ex.Message); throw new Exception(ex.Message, ex); } } return(RedirectToAction("Index")); } } return(View(admin)); }