public File ToFile(WorkLinqToSql.Document document) { string userName = "******"; try { CatalogDatabaseDataContext context = new CatalogDatabaseDataContext(); var author = (from user in context.AspNetUsers where (document.UserAuthor == user.Id) select user).Single(); userName = author.FirstName + author.LastName; } catch { } CatalogAppMVC.Models.File file = new File(document.Id, document.UserAuthor, document.DocumentName, document.DocumentType, document.FileName, document.FileType, document.Size, document.PathToFile); return(file); }
public WorkLinqToSql.AspNetRole GetUserRole(int userID) { CatalogDatabaseDataContext context = new CatalogDatabaseDataContext(); WorkLinqToSql.AspNetRole role = null; try { role = (from r in context.AspNetUserRoles where r.UserId == userID select r.AspNetRole).Single <AspNetRole>(); } catch { return(null); } return(role); }
public bool RemoveFile(int fileID) { try { CatalogDatabaseDataContext context = new CatalogDatabaseDataContext(); WorkLinqToSql.Document doc = (from file in context.Document where file.Id == fileID select file).Single <WorkLinqToSql.Document>(); context.Document.DeleteOnSubmit(doc); context.Document.Context.SubmitChanges(); } catch { return(false); } return(true); }
public bool UpdateStatusMachinery(Record.StatusType statusNew, int recordID) { try { WorkLinqToSql.CatalogDatabaseDataContext context = new CatalogDatabaseDataContext(); WorkLinqToSql.Machinery machinery = (from m in context.Machineries where m.Id == recordID select m).Single <WorkLinqToSql.Machinery>(); machinery.Status = (int)statusNew; context.Machineries.Context.SubmitChanges(); } catch { return(false); } return(true); }
public bool CreateAccess(AccessRoleCategory accessModel) { CatalogDatabaseDataContext context = new CatalogDatabaseDataContext(); try { WorkLinqToSql.AccessCatalogCategories access = new AccessCatalogCategories(); access.F = accessModel.CanDownloadFile; access.R = accessModel.CanRead; access.W = accessModel.CanWrite; access.RoleID = accessModel.RoleID; access.CategoryID = accessModel.CategoryID; context.AccessCatalogCategories.InsertOnSubmit(access); context.AccessCatalogCategories.Context.SubmitChanges(); } catch { return(false); } return(true); }
public int CreateCatalogCategories(Category categoryModel) { WorkLinqToSql.CatalogCategory category = new CatalogCategory(); try { CatalogDatabaseDataContext context = new CatalogDatabaseDataContext(); var categoryNames = from cat in context.CatalogCategories select cat.Name; if (!categoryNames.Contains(categoryModel.Name)) { category.Name = categoryModel.Name; context.CatalogCategories.InsertOnSubmit(category); context.CatalogCategories.Context.SubmitChanges(); } } catch { return(0); } return(category.Id); }