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
        [HttpPut] // Put Patrimonio - Edit/Update
        public JsonResult Edit(Patrimonios patrimonio)
        {
            if (ModelState.IsValid)
            {
                patrimonioDAL.Update(patrimonio);
                return(Json("Patrimonio alterado 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)));
            }
        }