Exemplo n.º 1
0
        public HttpResponseMessage Incluir(CadComposicaoControle model)
        {
            var context = new AlvoradaContext();

            try
            {
                context.CadComposicoesControle.Add(model);
                context.SaveChanges();
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Exemplo n.º 2
0
        public HttpResponseMessage Editar([FromBody] CadComposicaoControle obj)
        {
            var context = new AlvoradaContext();

            try
            {
                obj.DataAlteracao        = DateTime.Now;
                context.Entry(obj).State = EntityState.Modified;
                context.SaveChanges();
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Exemplo n.º 3
0
        public HttpResponseMessage Baixar(CadComposicaoControle model)
        {
            var context = new AlvoradaContext();

            try
            {
                model.Baixa                = false;
                model.DataBaixa            = DateTime.Now;
                context.Entry(model).State = EntityState.Modified;
                context.SaveChanges();
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Exemplo n.º 4
0
        public HttpResponseMessage Excluir([FromBody] CadComposicaoControle obj)
        {
            var context = new AlvoradaContext();

            try
            {
                context.Entry(obj).State = EntityState.Deleted;
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse <dynamic>(HttpStatusCode.InternalServerError, new
                {
                    Error = ex.Message
                }));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }