public static LinhasAcordoPrecos Update(LinhasAcordoPrecos item)
        {
            try
            {
                using (var ctx = new SuchDBContext())
                {
                    ctx.LinhasAcordoPrecos.Update(item);
                    ctx.SaveChanges();
                }

                return(item);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
 public static LinhasAcordoPrecos Create(LinhasAcordoPrecos item)
 {
     try
     {
         using (var ctx = new SuchDBContext())
         {
             item.DataCriacao = DateTime.Now;
             ctx.LinhasAcordoPrecos.Add(item);
             ctx.SaveChanges();
         }
         return(item);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
        public static bool DeleteByProcedimento(string NoProcedimento)
        {
            try
            {
                using (var ctx = new SuchDBContext())
                {
                    LinhasAcordoPrecos userLinhasAcordoPrecos = ctx.LinhasAcordoPrecos.Where(x => x.NoProcedimento == NoProcedimento).FirstOrDefault();

                    if (userLinhasAcordoPrecos != null)
                    {
                        ctx.LinhasAcordoPrecos.Remove(userLinhasAcordoPrecos);
                        ctx.SaveChanges();
                        return(true);
                    }
                }
            }
            catch { }
            return(false);
        }
 public static bool Delete(string NoProcedimento, string NoFornecedor, string CodProduto, DateTime DtValidadeInicio, string Cresp, string Localizacao)
 {
     try
     {
         using (var ctx = new SuchDBContext())
         {
             LinhasAcordoPrecos userLinhasAcordoPrecos = ctx.LinhasAcordoPrecos.Where(x => x.NoProcedimento == NoProcedimento && x.NoFornecedor == NoFornecedor &&
                                                                                      x.CodProduto == CodProduto && x.DtValidadeInicio == DtValidadeInicio &&
                                                                                      x.Cresp == Cresp && x.Localizacao == Localizacao).FirstOrDefault();
             if (userLinhasAcordoPrecos != null)
             {
                 ctx.LinhasAcordoPrecos.Remove(userLinhasAcordoPrecos);
                 ctx.SaveChanges();
                 return(true);
             }
         }
     }
     catch { }
     return(false);
 }