示例#1
0
        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));
        }
示例#2
0
        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"));
        }
示例#3
0
 public ResponseModel <List <PersonsModel> > CreatePerson(PersonsModel model)
 {
     _logger.Debug($"CreatePerson with payload: {JsonConvert.SerializeObject(model)}");
     return(_personService.CreatePerson(model));
 }