public async Task Create(MovimientoUnidadOrg model) { try { _db.bdSetMovimientoUnidadOrg.Add(model); await _db.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Update(MovimientoUnidadOrg model) { try { var _model = await _db.bdSetMovimientoUnidadOrg.FirstOrDefaultAsync(e => e.Id == model.Id); if (_model != null) { _db.Entry(_model).CurrentValues.SetValues(model); await _db.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
[Authorize] public async Task <IHttpActionResult> Create([FromBody] MovimientoUnidadOrg model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await _entityRepo.Create(model); return(Ok("Registro creado exitosamente!")); } catch (Exception e) { return(InternalServerError(e)); } }