コード例 #1
0
        public static new List <SQLLINQ.Models.CompanyFile> List()
        {
            var dc       = new SQLLINQ.Models.FMSContext();
            var dbFile   = dc.CompanyFile.Where(x => x.IsDeleted == false).ToList();
            var fileList = new List <SQLLINQ.Models.CompanyFile>();

            //var compId = dc.Company.Where(x => x.CompanyId);

            foreach (var compFile in dbFile)
            {
                var model = new SQLLINQ.Models.CompanyFile();
                model.FileId       = compFile.FileId;
                model.CompanyId    = compFile.CompanyId;
                model.FileName     = compFile.FileName;
                model.FileType     = compFile.FileType;
                model.RawFileName  = compFile.RawFileName;
                model.Description  = compFile.Description;
                model.Size         = compFile.Size;
                model.UploadDate   = compFile.UploadDate;
                model.ModifiedDate = compFile.ModifiedDate;
                model.Favorite     = compFile.Favorite;
                fileList.Add(model);
            }
            return(fileList.OrderBy(x => x.FileName).ToList());
        }
コード例 #2
0
        public static bool setRestore(string id)
        {
            try
            {
                var dc     = new SQLLINQ.Models.FMSContext();
                var dbFile = new SQLLINQ.Models.CompanyFile();

                dbFile = dc.CompanyFile.Where(x => x.FileId == Convert.ToInt64(id)).SingleOrDefault();
                if (dbFile != null)
                {
                    dbFile.IsDeleted = false;
                }
                dc.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #3
0
        public FileModel Save(FileModel file)
        {
            var dc     = new SQLLINQ.Models.FMSContext();
            var dbFile = new SQLLINQ.Models.CompanyFile();

            if (file.FileID == -1)
            {
                dbFile.CompanyId    = file.CompanyID;
                dbFile.FileName     = file.FileName;
                dbFile.FileType     = file.FileType;
                dbFile.RawFileName  = file.RawFileName;
                dbFile.Description  = file.Description;
                dbFile.Size         = file.Size;
                dbFile.UploadDate   = file.UploadDate;
                dbFile.ModifiedDate = file.ModifiedDate;
                dbFile.Favorite     = file.Favorite;
                dc.CompanyFile.Add(dbFile);
            }
            else
            {
                dbFile = dc.CompanyFile.Where(x => x.FileId == file.FileID).FirstOrDefault();
                if (dbFile != null)
                {
                    dbFile.FileId       = file.FileID;
                    dbFile.CompanyId    = file.CompanyID;
                    dbFile.FileName     = file.FileName;
                    dbFile.FileType     = file.FileType;
                    dbFile.RawFileName  = file.RawFileName;
                    dbFile.Description  = file.Description;
                    dbFile.Size         = file.Size;
                    dbFile.UploadDate   = file.UploadDate;
                    dbFile.ModifiedDate = file.ModifiedDate;
                    dbFile.Favorite     = file.Favorite;
                }
            }
            dc.SaveChanges();

            return(file);
        }
コード例 #4
0
        public static bool setFavorite(string id)
        {
            var dc     = new SQLLINQ.Models.FMSContext();
            var dbFile = new SQLLINQ.Models.CompanyFile();
            var fav    = 0;

            dbFile = dc.CompanyFile.Where(x => x.FileId == Convert.ToInt64(id)).SingleOrDefault();
            if (dbFile != null)
            {
                if (dbFile.Favorite != 1)
                {
                    fav = 1;
                }
            }
            if (dbFile.Favorite != 0)
            {
                fav = 0;
            }
            dbFile.Favorite = fav;
            dc.SaveChanges();

            return(true);
        }