Example #1
0
        public ResultAPI Del_lst(GetnID data)
        {
            ResultAPI result = new ResultAPI();

            db = new PTTGSP_DWSContext();
            if (data.nID.Count > 0)
            {
                var del_Materials = db.TB_Materials.Where(w => data.nID.Contains(w.nMaterialID)).ToList();
                foreach (var i in del_Materials)
                {
                    i.IsDel = true;
                    db.SaveChanges();
                }
                db = new PTTGSP_DWSContext();
                var del_Materials_File = db.TB_Materials_File.Where(w => data.nID.Contains(w.nMaterialID)).ToList();
                db.TB_Materials_File.RemoveRange(del_Materials_File);
                foreach (var item in data.nID)
                {
                    string Path            = "/UploadFile/Supplies/Supplies_" + item;
                    bool   directoryExists = Directory.Exists(Path);
                    Directory.Delete(Path, true);
                    Console.WriteLine("top-level directory exists: " + directoryExists);
                }

                db.SaveChanges();

                result.Status = ResultStatus.Success;
            }
            else
            {
                result.Status = ResultStatus.Warning;
            }
            return(result);
        }
        public ResultAPI Del_lst(GetnID data)
        {
            ResultAPI result = new ResultAPI();

            if (data.nID.Count > 0)
            {
                var qData = db.TB_Vendor.Where(w => data.nID.Contains(w.nVendorID)).ToList();
                foreach (var i in qData)
                {
                    i.IsDel = true;
                    db.SaveChanges();
                }
                db.SaveChanges();

                result.Status = ResultStatus.Success;
            }
            else
            {
                result.Status = ResultStatus.Warning;
            }
            return(result);
        }