Пример #1
0
        public ResultAndError <FamilyProvider> Add(FamilyProvider c)
        {
            ResultAndError <FamilyProvider> result = new ResultAndError <FamilyProvider>();

            try
            {
                db.FamilyProviders.Add(c);
                db.SaveChanges();
                return(result.AddResult(c));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Пример #2
0
        public bool DeleteMulti(IEnumerable <string> FamilyProviders)
        {
            List <FamilyProvider> oFamilyProviders = new List <FamilyProvider>();

            foreach (string FamilyProviderNo in FamilyProviders)
            {
                FamilyProvider oFamilyProvider = Get(FamilyProviderNo);
                if (oFamilyProvider != null)
                {
                    oFamilyProviders.Add(oFamilyProvider);
                }
            }
            db.FamilyProviders.RemoveRange(oFamilyProviders);
            db.SaveChanges();
            return(true);
        }
Пример #3
0
 public bool UpdateMulti(IEnumerable <FamilyProvider> oFamilyProviders, bool insertIfNoExists = false)
 {
     foreach (FamilyProvider FamilyProvider in oFamilyProviders)
     {
         FamilyProvider old = Get(FamilyProvider.VendorNo);
         if (old == null && insertIfNoExists)
         {
             Add(FamilyProvider);
         }
         else
         {
             db.Entry(old).CurrentValues.SetValues(FamilyProvider);
         }
     }
     db.SaveChanges();
     return(true);
 }
Пример #4
0
        public ResultAndError <FamilyProvider> Update(FamilyProvider cr, bool insertIfNoExists = false)
        {
            ResultAndError <FamilyProvider> result = new ResultAndError <FamilyProvider>();

            try
            {
                FamilyProvider old = Get(cr.VendorNo);
                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));
            }
        }
Пример #5
0
        public ResultAndError <bool> Delete(string id)
        {
            ResultAndError <bool> result = new ResultAndError <bool>();

            try
            {
                FamilyProvider FamilyProvider = Get(id);
                if (FamilyProvider == null)
                {
                    return(result.AddError("No se encontro la tarifa con el id " + id));
                }
                db.FamilyProviders.Remove(FamilyProvider);
                db.SaveChanges();
                return(result.AddResult(true));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
 public IActionResult UpdFamilyProvider([FromBody] FamilyProvider familyProvider, bool insertIfNoExists = false)
 {
     return(Ok(fBS.Update(familyProvider, insertIfNoExists)));
 }