public ActionResult AddLecturer(string name, string surname, string secondName, string email, string position, string telephone, int department, string admin = "off") { Messages messages = new Messages(); try { Lecturer.AddLecturer(name, surname, secondName, email, position, telephone, department, admin == "on"); messages.Add(Messages.Message.TypeMessage.good, string.Format("Пользователь {0} {1} {2} был добавлен", name, surname, secondName)); } catch (ValidationDataException error) { Messages erorrMessages = error.GetValue(); foreach (Messages.Message item in erorrMessages) { switch (item.Value) { case "no email": messages.Add(Messages.Message.TypeMessage.error, "Вы ввели не правильный email"); break; } } } TempData["messages"] = messages; return(Redirect("/Admin")); }
protected void btnCreate_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(txtName.Text)) { try { Lecturer.AddLecturer(txtName.Text); lblStatus_CreateLecturer.CssClass = "bg-success"; lblStatus_CreateLecturer.Text = "Lecturer was added successfully!"; // Response.Redirect("Index.aspx"); } catch (Exception ex) { lblStatus_CreateLecturer.CssClass = "bg-danger"; lblStatus_CreateLecturer.Text = "Lecturer was not added! Error: " + ex.Message; } } else { lblStatus_CreateLecturer.CssClass = "bg-danger"; lblStatus_CreateLecturer.Text = "Lecturer was not added!"; } }