public IActionResult Create([Bind("PersonId,PersonType,FirstName,MiddleName,LastName")] Person person) { if (ModelState.IsValid) { _personRepo.Add(person); _personRepo.Save(); return RedirectToAction(nameof(Index)); } return View(person); }
public ActionResult Create([Bind(Include = "Id,Name,LastName,EMail,Phone")] Person person) { if (ModelState.IsValid) { if (repo.Add(person) > 0) { return(RedirectToAction("Index")); } throw new Exception("Db Exception"); } return(View(person)); }
public void AddRecipient(Person person) { if (!Repo.GetList().Contains(person)) { Repo.Add(person); Logger.Write(string.Format("added {0}", person)); } else { throw new AlreadyExistsException(); } }
int IPersonManager.Create(PersonCreateRequest item) { var rnd = new Random(); var result = new Person() { Id = rnd.Next(51, 100), FirstName = item.FirstName, LastName = item.LastName, Email = item.Email, Company = item.Company, Age = item.Age }; _personRepo.Add(result); return(result.Id); }
public async Task <ActionResult <PersonModel> > PostEvent([FromBody] PersonModel personModel) { try { _personRepo.Add(personModel); if (await _personRepo.Save()) { return(Created($"/api/v1.0/Person/{personModel.ID}", personModel)); } } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}")); } return(BadRequest()); }
public void SavePersonsExam(Person person) { _personRepo.Add(person); }
public Person Add(Person person) { return(_personRepo.Add(person)); }