示例#1
0
 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;
     }
 }
示例#2
0
        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);
        }
示例#3
0
        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();
        }
示例#4
0
 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 }));
     }
 }
示例#5
0
 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 }));
     }
 }
示例#6
0
 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 }));
     }
 }
示例#7
0
 public void Update(TB_LEILAO Leilao)
 {
     try
     {
         ValidateFields(Leilao);
         leilaoRepository.Update(Leilao);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#8
0
 public void InsertLeilao(TB_LEILAO Leilao)
 {
     try
     {
         ValidateFields(Leilao);
         leilaoRepository.Insert(Leilao);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#9
0
        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;
            }
        }
示例#10
0
 public void Update(TB_LEILAO Leilao)
 {
     db.TB_LEILAO.Attach(Leilao);
     db.Entry(Leilao).State = EntityState.Modified;
     db.SaveChanges();
 }
示例#11
0
 public void Insert(TB_LEILAO Leilao)
 {
     db.TB_LEILAO.Add(Leilao);
     db.SaveChanges();
 }