private async Task insertaAdjuntosCompetidor(string autor, long IdAdjunto, string tipo, int idcompetidor) { try { AdjuntoPorCompetidor obj = new AdjuntoPorCompetidor(); obj.Autor = autor; obj.FechaRegistro = DateTime.Now; obj.Estado = true; obj.AdjuntoId = IdAdjunto; obj.CompetidorId = idcompetidor; if (tipo.ToLower() == "tarifa") { obj.Tarifa = true; } if (tipo.ToLower() == "vtc") { obj.VTC = true; } var entities = _dbComp.AdjuntoPorCompetidor.Add(obj); await _dbComp.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Create(AdjuntoPorCompetidor model) { try { _db.AdjuntoPorCompetidor.Add(model); await _db.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Update(AdjuntoPorCompetidor model) { try { var _model = await _db.AdjuntoPorCompetidor.FirstOrDefaultAsync(e => e.AdjuntoPorCompetidorId == model.AdjuntoPorCompetidorId); if (_model != null) { _db.Entry(_model).CurrentValues.SetValues(model); await _db.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task UpdateEstado(AdjuntoPorCompetidor model) { try { var _model = await _db.AdjuntoPorCompetidor.FirstOrDefaultAsync(e => e.AdjuntoPorCompetidorId == model.AdjuntoPorCompetidorId); if (_model != null) { _model.Estado = model.Estado; await _db.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task <IHttpActionResult> UpdateEstado([FromBody] AdjuntoPorCompetidor model) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _entityRepo.UpdateEstado(model); return(Ok()); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
public async Task <IHttpActionResult> Update([FromBody] AdjuntoPorCompetidor 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)); } }
[Authorize] public async Task <IHttpActionResult> Create([FromBody] AdjuntoPorCompetidor model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _entityRepo.Create(model); return(Ok("Registro creado exitosamente!")); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); if (e.Message.Substring(0, 44) == "An error occurred while updating the entries") { return(BadRequest("Ya existe un registro con ese nombre")); } return(InternalServerError(e)); } }