Example #1
0
 public async Task Create(SitioInteres model)
 {
     try
     {
         model.FechaRegistro = DateTime.Now;
         _db.DbSetSitioInteres.Add(model);
         await _db.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }
Example #2
0
        public async Task Update(SitioInteres model)
        {
            try
            {
                var _model = await _db.DbSetSitioInteres.FirstOrDefaultAsync(e => e.SitioId == model.SitioId);

                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> Update([FromBody] SitioInteres model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                log.Info(new MDCSet(this.ControllerContext.RouteData));
                await _entityRepo.Update(model);

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