protected override string Add(string input) { string[] parameters = input.Split('|'); Student result = model.Add(int.Parse(parameters[0]), parameters[1], int.Parse(parameters[2])); return("Obect was successfully created:\n" + "+---+--------------+---+\n" + string.Format(Student.OutputPattern, "Id", "Name", "Age") + "+---+--------------+---+\n" + result.ToString()); }
public ActionResult AddStudentHandler(FormCollection form) { Student student = new Student() { UserName = form["username"], Password = form["password"], Name = form["name"], Gender = form["gender"] != null, Email = form["email"], PhoneNumber = form["phone"], Id = form["id"], DayOfBirth = DateTime.Parse(form["dayOfBirth"]), School = form["school"], Grade = Convert.ToInt32(form["grade"]) }; StudentModel studentModel = new StudentModel(); studentModel.Add(student); return(RedirectToAction("ListStudents")); }
public void Add() { Id = -1; try { Student stu = new Student(); stu.Title = Title; stu.FirstName = Firstname; stu.LastName = Lastname; stu.PhoneNo = Phoneno; stu.Email = Email; stu.DivisionId = DivisionId; Id = _model.Add(stu); } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } }