Exemple #1
0
        public ResultAndError <PedVentaCab> Add(PedVentaCab c)
        {
            ResultAndError <PedVentaCab> result = new ResultAndError <PedVentaCab>();

            try
            {
                db.PedVentaCabs.Add(c);
                db.SaveChanges();
                return(result.AddResult(c));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Exemple #2
0
        public bool DeleteMulti(IEnumerable <string> PedVentaCabs)
        {
            List <PedVentaCab> oAlbaran = new List <PedVentaCab>();

            foreach (string PedVentaCabsNo in PedVentaCabs)
            {
                PedVentaCab oPedVentaCabs = Get(PedVentaCabsNo);
                if (oPedVentaCabs != null)
                {
                    oAlbaran.Add(oPedVentaCabs);
                }
            }
            db.PedVentaCabs.RemoveRange(oAlbaran);
            db.SaveChanges();
            return(true);
        }
Exemple #3
0
 public bool UpdateMulti(IEnumerable <PedVentaCab> oPedVentaCabs, bool insertIfNoExists = false)
 {
     foreach (PedVentaCab albaran in oPedVentaCabs)
     {
         PedVentaCab old = Get(albaran.No);
         if (old == null && insertIfNoExists)
         {
             Add(albaran);
         }
         else
         {
             db.Entry(old).CurrentValues.SetValues(albaran);
         }
     }
     db.SaveChanges();
     return(true);
 }
Exemple #4
0
        public ResultAndError <bool> UpdateReadingDate(IEnumerable <string> centersNo, DateTimeOffset readingDate)
        {
            ResultAndError <bool> result = new ResultAndError <bool>();

            try
            {
                foreach (string no in centersNo)
                {
                    PedVentaCab oPedVentaCabs = Get(no);
                    oPedVentaCabs.ReadingDate = readingDate;
                    db.SaveChanges();
                }
                return(result.AddResult(true));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Exemple #5
0
        public ResultAndError <bool> Delete(string id)
        {
            ResultAndError <bool> result = new ResultAndError <bool>();

            try
            {
                PedVentaCab PedVentaCabs = Get(id);
                if (PedVentaCabs == null)
                {
                    return(result.AddError("No se encontro la tarifa con el id " + id));
                }
                db.PedVentaCabs.Remove(PedVentaCabs);
                db.SaveChanges();
                return(result.AddResult(true));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Exemple #6
0
        public ResultAndError <PedVentaCab> Update(PedVentaCab cr, bool insertIfNoExists = false)
        {
            ResultAndError <PedVentaCab> result = new ResultAndError <PedVentaCab>();

            try
            {
                PedVentaCab old = Get(cr.No);
                if (old == null && insertIfNoExists)
                {
                    return(Add(cr));
                }
                db.Entry(old).CurrentValues.SetValues(cr);
                db.SaveChanges();
                return(result.AddResult(cr));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
 public PedVentaCab_View(PedVentaCab p)
 {
     No = p.No;
     BillToCustomerNo       = p.BillToCustomerNo;
     BillToName             = p.BillToName ?? "";
     BillToName2            = p.BillToName2 ?? "";
     BillToAddress          = p.BillToAddress ?? "";
     BillToAddress2         = p.BillToAddress2 ?? "";
     BillToCity             = p.BillToCity ?? "";
     BillToContact          = p.BillToContact ?? "";
     OrderDate              = p.OrderDate ?? DateTimeOffset.MinValue;
     ShortcutDimension1Code = p.ShortcutDimension1Code ?? "";
     ShortcutDimension2Code = p.ShortcutDimension2Code ?? "";
     VATRegistrationNo      = p.VATRegistrationNo ?? "";
     BillToPostCode         = p.BillToPostCode ?? "";
     BillToCounty           = p.BillToCounty ?? "";
     BillToCountry          = p.BillToCountry ?? "";
     DocumentDate           = p.DocumentDate ?? DateTimeOffset.MinValue;
     Comment = p.Comment ?? "";
     BillToContactTelefono = p.BillToContactTelefono ?? "";
     ReadingDate           = p.ReadingDate ?? DateTimeOffset.MinValue;
 }
Exemple #8
0
 public IActionResult UpdPedVentaCab([FromBody] PedVentaCab PedVentaCab, bool insertIfNoExists = false)
 {
     return(Ok(pBS.Update(PedVentaCab, insertIfNoExists)));
 }