Exemplo n.º 1
0
        public IActionResult Post([FromForm] LodgingModel lodgingModel)
        {
            IActionResult result;

            if (lodgingModel.HasErrors())
            {
                result = BadRequest(new ErrorModel(lodgingModel.Errors()));
            }
            else
            {
                var lodging = LodgingLogic.Create(lodgingModel.ToEntity());
                result = Created("GetAdministrator", new LodgingBasicInfoModel(lodging));
            }

            return(result);
        }
        public void IsValidReturnsTrueIfEntityIsNotValid()
        {
            var lodging = LodgingModel.ToEntity();

            Assert.AreEqual(lodging.Validate().HasErrors(), LodgingModel.HasErrors());
        }