public void ValidateFields(TB_LEILAO Leilao) { try { if (string.IsNullOrEmpty(Leilao.DS_NOME_LEILAO)) { throw new Exception("Favor inserir um nome para o leilão!"); } if (Leilao.DT_ABERTURA == null) { throw new Exception("A data de abertura não pode ser nula!"); } if (Leilao.DT_FINALIZACAO == null) { throw new Exception("A data de finalização não pode ser nula!"); } if (Leilao.DT_FINALIZACAO < Leilao.DT_ABERTURA) { throw new Exception("A data de finalização não pode ser anterior a data de abertura!"); } if (Leilao.ID_USUARIO_RESPONSAVEL == 0 || Leilao.ID_USUARIO_RESPONSAVEL == null) { throw new Exception("Favor inserir um usuário responsável!"); } } catch (Exception ex) { throw ex; } }
public TB_LEILAO GetById(int ID_LEILAO) { TB_LEILAO Leilao = new TB_LEILAO(); Leilao = db.TB_LEILAO.Where(l => l.ID_LEILAO == ID_LEILAO).FirstOrDefault(); return(Leilao); }
public void Delete(int ID_LEILAO) { TB_LEILAO leilao = new TB_LEILAO(); leilao = db.TB_LEILAO.Find(ID_LEILAO); db.TB_LEILAO.Attach(leilao); db.TB_LEILAO.Remove(leilao); db.SaveChanges(); }
public HttpResponseMessage Update(TB_LEILAO Leilao) { try { leilaoService.Update(Leilao); return(Request.CreateResponse(HttpStatusCode.OK, new { message = "Leilão atualizado com sucesso!" })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new { message = ex.Message })); } }
public HttpResponseMessage GetById(int ID_LEILAO) { try { TB_LEILAO Leilao = leilaoService.GetById(ID_LEILAO); return(Request.CreateResponse(HttpStatusCode.OK, new { Leilao })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new { message = ex.Message })); } }
public HttpResponseMessage Insert(TB_LEILAO Leilao) { try { leilaoService.InsertLeilao(Leilao); return(Request.CreateResponse(HttpStatusCode.OK, new { message = "Leilão cadastrado com sucesso!" })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new { message = ex.Message })); } }
public void Update(TB_LEILAO Leilao) { try { ValidateFields(Leilao); leilaoRepository.Update(Leilao); } catch (Exception ex) { throw; } }
public void InsertLeilao(TB_LEILAO Leilao) { try { ValidateFields(Leilao); leilaoRepository.Insert(Leilao); } catch (Exception ex) { throw ex; } }
public TB_LEILAO GetById(int ID_LEILAO) { try { if (string.IsNullOrEmpty(ID_LEILAO.ToString())) { throw new Exception("Favor passar um ID válido de leilão"); } TB_LEILAO Leilao = leilaoRepository.GetById(ID_LEILAO); return(Leilao); } catch (Exception ex) { throw ex; } }
public void Update(TB_LEILAO Leilao) { db.TB_LEILAO.Attach(Leilao); db.Entry(Leilao).State = EntityState.Modified; db.SaveChanges(); }
public void Insert(TB_LEILAO Leilao) { db.TB_LEILAO.Add(Leilao); db.SaveChanges(); }