public static string Copy(Guid OrgId, int DepartmentId, int TypeID, int CategoryID) { using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection)) { var Types = from t in dc.AssetTypes where t.Id == TypeID && t.DepartmentId == DepartmentId select t; var Type = Types.FirstOrNull(); if (Type == null) { return("Can not find specified asset type."); } Types = from t in dc.AssetTypes where t.DepartmentId == DepartmentId && t.CategoryId == CategoryID && t.Name == Type.Name select t; var ExistType = Types.FirstOrNull(); if (ExistType != null) { return("This asset type exist in destination asset category."); } lib.bwa.bigWebDesk.LinqBll.Context.AssetTypes NewType = new lib.bwa.bigWebDesk.LinqBll.Context.AssetTypes(); NewType.CategoryId = CategoryID; NewType.DepartmentId = DepartmentId; NewType.ConfigCustFields = Type.ConfigCustFields; NewType.Name = Type.Name; dc.AssetTypes.InsertOnSubmit(NewType); dc.SubmitChanges(); return(null); } }
public static string Copy(Guid OrgId, int DepartmentId, int TypeID, int CategoryID) { using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection)) { var Types = from t in dc.AssetTypes where t.Id == TypeID && t.DepartmentId == DepartmentId select t; var Type = Types.FirstOrNull(); if (Type == null) return "Can not find specified asset type."; Types = from t in dc.AssetTypes where t.DepartmentId == DepartmentId && t.CategoryId == CategoryID && t.Name == Type.Name select t; var ExistType = Types.FirstOrNull(); if (ExistType != null) return "This asset type exist in destination asset category."; lib.bwa.bigWebDesk.LinqBll.Context.AssetTypes NewType = new lib.bwa.bigWebDesk.LinqBll.Context.AssetTypes(); NewType.CategoryId = CategoryID; NewType.DepartmentId = DepartmentId; NewType.ConfigCustFields = Type.ConfigCustFields; NewType.Name = Type.Name; dc.AssetTypes.InsertOnSubmit(NewType); dc.SubmitChanges(); return null; } }