public async Task <IHttpActionResult> salvaCampo([FromBody] CampoModel model)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            try
            {
                using (TesteContext db = new TesteContext())
                {
                    CAMPO campo = new CAMPO();
                    campo.Nome  = model.Nome;
                    campo.Ativo = false;
                    db.Campo.Add(campo);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("Post", "Site temporariamente indisponível. Tente mais tarde.");
                return(BadRequest(ModelState));
            }

            return(Ok(model));
        }
Example #2
0
 public CampoWrapperViewModel(CampoModel campo)
 {
     _campoModel = campo;
     Buracos     = new ObservableCollection <BuracoWrapperViewModel>(_campoModel.Buracos.Select(p => new BuracoWrapperViewModel(p)));
 }