public async Task UpdateStadoOrCreate(LikesLinked model) { try { var _model = await _db.bdSetLikesLinked.FirstOrDefaultAsync( e => e.Aprobador.Equals(model.Aprobador) && e.Empleado.Equals(model.Empleado) && e.IdExteno.Equals(model.IdExteno) && e.Tipo == 1); if (_model != null) { model.Id = _model.Id; _db.Entry(_model).CurrentValues.SetValues(model); await _db.SaveChangesAsync(); } else { await this.Create(model); } } catch (Exception e) { throw new Exception(e.Message, e); } }
private async Task Create(LikesLinked model) { try { _db.bdSetLikesLinked.Add(model); await _db.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Update(LikesLinked model) { try { var _model = await _db.bdSetLikesLinked.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); } }
public async Task <IHttpActionResult> Update([FromBody] LikesLinked model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await _entityRepo.Update(model); return(Ok("Registro actualizado exitosamente!")); } catch (Exception e) { return(InternalServerError(e)); } }