public ActionResult Create([FromBody] PersonViewModel model) { try { if (ModelState.IsValid) { var personEntity = new PersonEntity { Name = model.Name, LastName = model.LastName, Email = model.Email, Address = model.Address, MobilePhone = model.MobilePhone, Birthday = model.Birthday }; _personsService.CreatePerson(personEntity); ViewBag.RegisteredUser = true; return(RedirectToAction("Index")); } } catch { ModelState.AddModelError("", "Nepavyko sukurti vartotojo!"); } return(View(model)); }
public void PersonTests_AddPerson() { //Arrange var model = new PersonsBuilder() .WithRandomProps() .WithCode(4) .WithName("TestCaseUserAddTest") .WithSurname("TestCaseSurNameAddTest") .WithIdNumber("82xx0751xxxxx") .WithActive(true) .Build(); //Act _service.CreatePerson(model); //Assert Assert.IsTrue(_context.Person.Any(i => i.IdNumber == "82xx0751xxxxx")); }
public ResponseModel <List <PersonsModel> > CreatePerson(PersonsModel model) { _logger.Debug($"CreatePerson with payload: {JsonConvert.SerializeObject(model)}"); return(_personService.CreatePerson(model)); }