Exemple #1
0
        public async Task <int> DeletePacking(int id)
        {
            try
            {
                Packing pack = await getPackingById(id);

                if (pack != null)
                {
                    sde.Products.RemoveRange(pack.Products);
                    await sde.SaveChangesAsync();

                    sde.Packings.Remove(pack);
                    sde.SaveChanges();
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
 public async Task <Packing> getPackingById(int id)
 {
     try
     {
         Packing pack = await(from p in sde.Packings where p.packingId == id select p).FirstOrDefaultAsync();
         return(pack);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
 public async Task AddPacking(Packing pack)
 {
     try
     {
         sde.Packings.Add(pack);
         await sde.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #4
0
        public async Task UpdatePacking(int id, Packing pack)
        {
            try
            {
                Packing old_pack = await getPackingById(id);

                old_pack.packingName = pack.packingName;
                old_pack.modifiedAt  = pack.modifiedAt;
                old_pack.modifiedBy  = pack.modifiedBy;

                sde.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }