Пример #1
0
 public ModuleModel GetModule(string moduleNumber)
 {
     vmsServerLinqDataContext datacontext = new vmsServerLinqDataContext();
     ModuleModel model = new ModuleModel();
     Module query = (from m in datacontext.Modules
                     where m.ModuleNumber == moduleNumber
                     select m).SingleOrDefault<Module>();
     model.ModuleNumber = query.ModuleNumber;
     model.ModuleType = query.ModuleType;
     model.IsActive = Convert.ToBoolean(query.IsActive);
     return model;
 }
Пример #2
0
        public void Save(ModuleModel model)
        {
            vmsServerLinqDataContext datacontext = new vmsServerLinqDataContext();
            Module objModule = new Module();
            try
            {
                objModule = datacontext.Modules.Single(m => m.ModuleNumber == model.ModuleNumber);

                objModule.ModuleNumber = model.ModuleNumber;
                objModule.ModuleType = model.ModuleType;
                objModule.IsActive = model.IsActive;
                datacontext.SubmitChanges();
            }
            catch
            {
                objModule.ModuleNumber = model.ModuleNumber;
                objModule.ModuleType = model.ModuleType;
                objModule.IsActive = model.IsActive;
                datacontext.Modules.InsertOnSubmit(objModule);
                datacontext.SubmitChanges();
            }
        }