예제 #1
0
 public async Task Create(CategoriasPorFamilia model)
 {
     try
     {
         _db.categoriasFamilia.Add(model);
         await _db.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }
예제 #2
0
        public async Task UpdateEstado(CategoriasPorFamilia obj)
        {
            try
            {
                var _obj = await _db.categoriasFamilia.FirstOrDefaultAsync(e => e.CategoriaId == obj.CategoriaId);

                if (_obj != null)
                {
                    _obj.Estado = obj.Estado;
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
예제 #3
0
        public async Task Update(CategoriasPorFamilia model)
        {
            try
            {
                var _model = await _db.categoriasFamilia.FirstOrDefaultAsync(e => e.CategoriaId == model.CategoriaId);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
                                                               public async Task <IHttpActionResult> UpdateEstado(CategoriasPorFamilia obj)
                                                               {
                                                                   try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                         await _repository.UpdateEstado(obj);

                                                                         return(Ok("Registro actualizado correctamente!")); }
                                                                   catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                                                                                         return(InternalServerError(e)); }
                                                               }
                                                               [HttpPost][Authorize] public async Task <IHttpActionResult> Create(CategoriasPorFamilia obj)
                                                               {
                                                                   try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                         await _repository.Create(obj);

                                                                         return(Ok("Categoría registrada correctamente!")); }
                                                                   catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                         return(InternalServerError(e)); }
                                                               }