public ApplicationUser Create(ApplicationUser applicationUser) { if (IsPermissionAllowed(applicationUser)) { int tenantId = applicationUser.UserTenants.FirstOrDefault().TenantId; applicationUser.UserTenants = null; bool userSucceeded = _accountProvider.Create(applicationUser, applicationUser.TemporaryCode); if (userSucceeded) { bool roleSucceeded = _accountProvider.AddToRole(applicationUser.Id, applicationUser.TemporaryRole); Tenant tenant = _db.Tenants.FirstOrDefault(t => t.TenantId == tenantId); ApplicationUser reloadedUser = _db.Users.Include(t => t.UserTenants).FirstOrDefault(u => u.Id == applicationUser.Id); reloadedUser.UserTenants = new List <Tenant> { tenant }; _db.Entry(reloadedUser).State = EntityState.Modified; _db.SaveChanges(); } else { Errors = new string[] { "User name already exists" }; } } return(applicationUser); }
public ActionResult Create([Bind(Include = "TenantId,Name,CreatedDate,UpdatedDate")] Tenant tenant) { if (ModelState.IsValid) { db.Tenants.Add(tenant); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tenant)); }
public ActionResult Create([Bind(Include = "LookupTypeId,Description,CreatedDate,UpdatedDate")] LookupType lookupType) { if (ModelState.IsValid) { db.LookupTypes.Add(lookupType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lookupType)); }
public ActionResult Create([Bind(Include = "LookupId,Description,LookupTypeId,CreatedDate,UpdatedDate")] Lookup lookup) { if (ModelState.IsValid) { db.Lookups.Add(lookup); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.LookupTypeId = new SelectList(db.LookupTypes, "LookupTypeId", "Description", lookup.LookupTypeId); return(View(lookup)); }
public ActionResult Create([Bind(Include = "QuoteRequestId,DateRequired,Quantity,SpecificationDetails,QuoteResponseId")] QuoteRequest quoteRequest) { if (ModelState.IsValid) { db.QuoteRequests.Add(quoteRequest); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.QuoteRequestId = new SelectList(db.QuoteResponses, "QuoteReposonseId", "Notes", quoteRequest.QuoteRequestId); return(View(quoteRequest)); }
public ActionResult Create([Bind(Include = "QuoteReposonseId,QuoteCostPerItem,QuoteCostTotal,Notes,QuoteRequestId")] QuoteResponse quoteResponse) { if (ModelState.IsValid) { db.QuoteResponses.Add(quoteResponse); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.QuoteReposonseId = new SelectList(db.QuoteRequests, "QuoteRequestId", "SpecificationDetails", quoteResponse.QuoteReposonseId); return(View(quoteResponse)); }
public ActionResult DeleteConfirmed(string id) { ApplicationUser applicationUser = db.Users.Find(id); db.Users.Remove(applicationUser); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Contacts/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Contact contact = db.Contacts.Find(id); contact.MessageRead = true; db.Entry(contact).State = EntityState.Modified; db.SaveChanges(); if (contact == null) { return(HttpNotFound()); } return(View(contact)); }
private void SeedBasicApplicationSettings() { // Button panel if (!_context.ApplicationSettings.Any( x => x.AppSetting.Key == EnumHelper.ApplicationSettingKeys.DashboardButtonsPanel.ToString() && x.UserId == _userId)) { var setting = _context.Settings.FirstOrDefault(x => x.Key == EnumHelper.ApplicationSettingKeys.DashboardButtonsPanel.ToString()); ApplicationSetting appSetting = new ApplicationSetting { AppSetting = setting, ScopeType = EnumHelper.AppSettingScopeType.User, Value = "true", UserId = _userId }; _context.ApplicationSettings.Add(appSetting); _context.SaveChanges(); } // Notifications Panel if (!_context.ApplicationSettings.Any( x => x.AppSetting.Key == EnumHelper.ApplicationSettingKeys.DashboardNotificationsPanel.ToString() && x.UserId == _userId)) { var setting = _context.Settings.FirstOrDefault(x => x.Key == EnumHelper.ApplicationSettingKeys.DashboardNotificationsPanel.ToString()); ApplicationSetting appSetting = new ApplicationSetting { AppSetting = setting, ScopeType = EnumHelper.AppSettingScopeType.User, Value = "true", UserId = _userId }; _context.ApplicationSettings.Add(appSetting); _context.SaveChanges(); } // All asset pie char Panel if (!_context.ApplicationSettings.Any( x => x.AppSetting.Key == EnumHelper.ApplicationSettingKeys.DashboardAssetsPieChartPanel.ToString() && x.UserId == _userId)) { var setting = _context.Settings.FirstOrDefault(x => x.Key == EnumHelper.ApplicationSettingKeys.DashboardAssetsPieChartPanel.ToString()); ApplicationSetting appSetting = new ApplicationSetting { AppSetting = setting, ScopeType = EnumHelper.AppSettingScopeType.User, Value = "true", UserId = _userId }; _context.ApplicationSettings.Add(appSetting); _context.SaveChanges(); } // Obsolete panel if (!_context.ApplicationSettings.Any( x => x.AppSetting.Key == EnumHelper.ApplicationSettingKeys.DashboardAssetsObsoleteChartPanel.ToString() && x.UserId == _userId)) { var setting = _context.Settings.FirstOrDefault(x => x.Key == EnumHelper.ApplicationSettingKeys.DashboardAssetsObsoleteChartPanel.ToString()); ApplicationSetting appSetting = new ApplicationSetting { AppSetting = setting, ScopeType = EnumHelper.AppSettingScopeType.User, Value = "true", UserId = _userId }; _context.ApplicationSettings.Add(appSetting); _context.SaveChanges(); } // Warranty Panel if (!_context.ApplicationSettings.Any( x => x.AppSetting.Key == EnumHelper.ApplicationSettingKeys.DashboardAssetsWarrantyExpiryChartPanel.ToString() && x.UserId == _userId)) { var setting = _context.Settings.FirstOrDefault(x => x.Key == EnumHelper.ApplicationSettingKeys.DashboardAssetsWarrantyExpiryChartPanel.ToString()); ApplicationSetting appSetting = new ApplicationSetting { AppSetting = setting, ScopeType = EnumHelper.AppSettingScopeType.User, Value = "true", UserId = _userId }; _context.ApplicationSettings.Add(appSetting); _context.SaveChanges(); } // Wishlist panel if (!_context.ApplicationSettings.Any( x => x.AppSetting.Key == EnumHelper.ApplicationSettingKeys.DashboardAssetsWishlistStatsPanel.ToString() && x.UserId == _userId)) { var setting = _context.Settings.FirstOrDefault(x => x.Key == EnumHelper.ApplicationSettingKeys.DashboardAssetsWishlistStatsPanel.ToString()); ApplicationSetting appSetting = new ApplicationSetting { AppSetting = setting, ScopeType = EnumHelper.AppSettingScopeType.User, Value = "true", UserId = _userId }; _context.ApplicationSettings.Add(appSetting); _context.SaveChanges(); } }
/// <summary> /// Seed app settings - user level types /// </summary> private void SeedUserSettings() { // Dashboard Buttons Panel if (!_context.Settings.Any(x => x.Key.Equals(Helpers.EnumHelper.ApplicationSettingKeys.DashboardButtonsPanel.ToString(), StringComparison.CurrentCultureIgnoreCase))) { Setting appSetting = new Setting { Key = Helpers.EnumHelper.ApplicationSettingKeys.DashboardButtonsPanel.ToString(), DataType = EnumHelper.AppSettingDataType.Bool, //ScopeType = EnumHelper.AppSettingScopeType.User, SettingType = EnumHelper.ApplicationSettingType.Dashboard, //Value = "true" }; _context.Settings.Add(appSetting); _context.SaveChanges(); } // Dashboard Notifications Panel if (!_context.Settings.Any(x => x.Key.Equals(Helpers.EnumHelper.ApplicationSettingKeys.DashboardNotificationsPanel.ToString(), StringComparison.CurrentCultureIgnoreCase))) { Setting appSetting = new Setting { Key = Helpers.EnumHelper.ApplicationSettingKeys.DashboardNotificationsPanel.ToString(), DataType = EnumHelper.AppSettingDataType.Bool, //ScopeType = EnumHelper.AppSettingScopeType.User, SettingType = EnumHelper.ApplicationSettingType.Dashboard, //Value = "true" }; _context.Settings.Add(appSetting); _context.SaveChanges(); } // Dashboard All Assets Panel if (!_context.Settings.Any(x => x.Key.Equals(Helpers.EnumHelper.ApplicationSettingKeys.DashboardAssetsPieChartPanel.ToString(), StringComparison.CurrentCultureIgnoreCase))) { Setting appSetting = new Setting { Key = Helpers.EnumHelper.ApplicationSettingKeys.DashboardAssetsPieChartPanel.ToString(), DataType = EnumHelper.AppSettingDataType.Bool, //ScopeType = EnumHelper.AppSettingScopeType.User, SettingType = EnumHelper.ApplicationSettingType.Dashboard, //Value = "true" }; _context.Settings.Add(appSetting); _context.SaveChanges(); } // Dashboard All Assets Obsolete Panel if (!_context.Settings.Any(x => x.Key.Equals(Helpers.EnumHelper.ApplicationSettingKeys.DashboardAssetsObsoleteChartPanel.ToString(), StringComparison.CurrentCultureIgnoreCase))) { Setting appSetting = new Setting { Key = Helpers.EnumHelper.ApplicationSettingKeys.DashboardAssetsObsoleteChartPanel.ToString(), DataType = EnumHelper.AppSettingDataType.Bool, //ScopeType = EnumHelper.AppSettingScopeType.User, SettingType = EnumHelper.ApplicationSettingType.Dashboard, //Value = "true" }; _context.Settings.Add(appSetting); _context.SaveChanges(); } // Dashboard WarrantyExpiry Obsolete Panel if (!_context.Settings.Any(x => x.Key.Equals(Helpers.EnumHelper.ApplicationSettingKeys.DashboardAssetsWarrantyExpiryChartPanel.ToString(), StringComparison.CurrentCultureIgnoreCase))) { Setting appSetting = new Setting { Key = Helpers.EnumHelper.ApplicationSettingKeys.DashboardAssetsWarrantyExpiryChartPanel.ToString(), DataType = EnumHelper.AppSettingDataType.Bool, //ScopeType = EnumHelper.AppSettingScopeType.User, SettingType = EnumHelper.ApplicationSettingType.Dashboard, //Value = "true" }; _context.Settings.Add(appSetting); _context.SaveChanges(); } // Dashboard Wishlist Panel if (!_context.Settings.Any(x => x.Key.Equals(Helpers.EnumHelper.ApplicationSettingKeys.DashboardAssetsWishlistStatsPanel.ToString(), StringComparison.CurrentCultureIgnoreCase))) { Setting appSetting = new Setting { Key = Helpers.EnumHelper.ApplicationSettingKeys.DashboardAssetsWishlistStatsPanel.ToString(), DataType = EnumHelper.AppSettingDataType.Bool, //ScopeType = EnumHelper.AppSettingScopeType.User, SettingType = EnumHelper.ApplicationSettingType.Dashboard, //Value = "true" }; _context.Settings.Add(appSetting); _context.SaveChanges(); } }
public ApplicationUser EditUser(ApplicationUser user) { _context.Entry(user).State = EntityState.Modified; _context.SaveChanges(); return(user); }
/// <summary> /// Save the context to the DB /// </summary> public void Save() { dbContext.SaveChanges(); }
/// <summary> /// Save the context to the DB /// </summary> public void Save() { _db.SaveChanges(); }