public void AddTest()
        {
            PhoneBookContext _phonecontext    = new PhoneBookContext();
            ProducerConfig   _config          = new ProducerConfig();
            ValuesController valuesController = new ValuesController(_config, _phonecontext);

            var model = new ConnectionInfoAddDTO();

            model.PersonID = 1;


            var info = valuesController.Add(model);

            Assert.IsNotNull(info);
        }
Esempio n. 2
0
        public IActionResult Add([FromForm] ConnectionInfoAddDTO model)
        {
            if (ModelState.IsValid)
            {
                ConnectionInfo info = new ConnectionInfo();
                info.Phone    = model.Phone;
                info.Email    = model.Email;
                info.Location = model.Location;
                info.PersonID = model.PersonID;
                info.context  = model.context;
                _phonecontext.connectionInfos.Add(info);
                _phonecontext.SaveChanges();


                return(Ok(model));
            }
            else
            {
                return(BadRequest("This ID is not valid!!"));
            }
        }