private int getNumAssmnts(UASEntities uasCntxt) { try { uas_Config config = uasCntxt.uas_Config.Where(c => c.ConfigName == "NoGridAssmnts").FirstOrDefault(); if (config != null) { uas_ProfileConfig profileConfig = uasCntxt.uas_ProfileConfig.Where(p => p.ConfigID == config.ConfigID).FirstOrDefault(); if (profileConfig != null) { uas_UserProfile userProfile = uasCntxt.uas_UserProfile.Where(u => u.ProfileConfigID == profileConfig.ProfileConfigID && u.UserID == SessionHelper.LoginStatus.UserID).FirstOrDefault(); if (userProfile != null) { return(Int32.Parse(userProfile.OptionSet)); } } } } catch (Exception xcptn) { Debug.WriteLine("SearchModel.getNumAssmnts exception: " + xcptn.Message); } return(15); }
private uas_ProfileConfig newProfileConfig(PreferenceModel pref, uas_Config config) { uas_ProfileConfig profileConfig = new uas_ProfileConfig(); profileConfig.ConfigID = config.ConfigID; profileConfig.ProfileSet = null; pref.db.uas_ProfileConfig.Add(profileConfig); pref.db.SaveChanges(); profileConfig = pref.db.uas_ProfileConfig.Where(p => p.ConfigID == config.ConfigID).FirstOrDefault(); return(profileConfig); }
private uas_Config newConfig(PreferenceModel pref) { uas_Config config = new uas_Config(); config.ConfigName = "NoGridAssmnts"; config.ConfigParams = "number"; pref.db.uas_Config.Add(config); pref.db.SaveChanges(); config = pref.db.uas_Config.Where(c => c.ConfigName == "NoGridAssmnts").FirstOrDefault(); return(config); }
public ActionResult ChangeNum(PreferenceModel pref) { uas_Config config = pref.db.uas_Config.Where(c => c.ConfigName == "NoGridAssmnts").FirstOrDefault(); if (config != null) { uas_ProfileConfig profileConfig = pref.db.uas_ProfileConfig.Where(p => p.ConfigID == config.ConfigID).FirstOrDefault(); if (profileConfig != null) { uas_UserProfile userProfile = pref.db.uas_UserProfile.Where(u => u.ProfileConfigID == profileConfig.ProfileConfigID && u.UserID == SessionHelper.LoginStatus.UserID).FirstOrDefault(); if (userProfile != null) { userProfile.OptionSet = pref.numAssmnts; userProfile.ModifiedBy = SessionHelper.LoginStatus.UserID; userProfile.ModifiedDate = DateTime.Now; pref.db.Entry(userProfile).State = System.Data.Entity.EntityState.Modified; pref.db.SaveChanges(); } else { newUserProfile(pref, profileConfig); } } else { profileConfig = newProfileConfig(pref, config); newUserProfile(pref, profileConfig); } } else { config = newConfig(pref); uas_ProfileConfig profileConfig = newProfileConfig(pref, config); newUserProfile(pref, profileConfig); } return(RedirectToAction("Index", "Search")); }
public ActionResult indexUser(PreferenceModel pref) { uas_Config config = pref.db.uas_Config.Where(c => c.ConfigName == "NoGridAssmnts").FirstOrDefault(); if (config != null) { uas_ProfileConfig profileConfig = pref.db.uas_ProfileConfig.Where(p => p.ConfigID == config.ConfigID).FirstOrDefault(); if (profileConfig != null) { uas_UserProfile userProfile = pref.db.uas_UserProfile.Where(u => u.ProfileConfigID == profileConfig.ProfileConfigID && u.UserID == SessionHelper.LoginStatus.UserID).FirstOrDefault(); if (userProfile != null) { pref.numAssmnts = userProfile.OptionSet; } } } return(View("_Preferences1", pref)); }