Beispiel #1
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
            DAL.Load(Directory.GetCurrentDirectory() + @"\Connection.ini");

            MarcaDAL entMarca = new MarcaDAL();

            entMarca.nome = "MkAppTeste1";
            List <MarcaDAL> lm = entMarca.GetAll();

            entMarca.Insert();
            lm            = entMarca.GetAll();
            entMarca.nome = "MkAppTeste1Alt";
            entMarca.Update();
            lm = entMarca.GetAll();
            entMarca.Delete();
            lm = entMarca.GetAll();

            PatrimonioDAL entPatrimonio = new PatrimonioDAL();

            entPatrimonio.nome      = "PtrAppTeste1";
            entPatrimonio.descricao = "DescAppTeste";
            entPatrimonio.marcaId   = 1;
            entPatrimonio.numTombo  = "";
            List <PatrimonioDAL> lp = entPatrimonio.GetAll();

            entPatrimonio.Insert();
            lp = entPatrimonio.GetAll();
            entPatrimonio.nome = "PtrAppTeste1Alt";
            entPatrimonio.Update();
            lp = entPatrimonio.GetAll();
            entPatrimonio.Delete();
            lp = entPatrimonio.GetAll();
        }
Beispiel #2
0
        [HttpPost] // Post Patrimonio - Insert
        public JsonResult Insert(Patrimonios patrimonio)
        {
            patrimonio.PatrimonioID = Guid.NewGuid();
            if (ModelState.IsValid)
            {
                patrimonioDAL.Insert(patrimonio);
                return(Json("Patrimonio cadastrado com sucesso."));
            }
            else
            {
                List <string> errors = (from x in ModelState.Values
                                        from error in x.Errors
                                        select error.ErrorMessage).ToList();

                Response.StatusCode = 400;
                return(Json(string.Join(Environment.NewLine, errors)));
            }
        }