コード例 #1
0
        public HttpResponseMessage Incluir(CadEntradaControle model)
        {
            var context = new AlvoradaContext();

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

            catch (Exception ex)
            {
                throw ex;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
コード例 #2
0
        public HttpResponseMessage Editar(CadEntradaControle model)
        {
            var context = new AlvoradaContext();

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

            catch (Exception ex)
            {
                throw ex;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
コード例 #3
0
        public HttpResponseMessage Excluir([FromBody] CadEntradaControle 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));
        }