protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); #region Making sure ther is a default Admin available var adminEmail = "*****@*****.**"; var adminUser = Users.Get(adminEmail); if (adminUser.Id == Guid.Empty) { adminUser = new User { Id = Guid.NewGuid(), FirstName = "Admin", LastName = "Admin", Username = "******", Email = adminEmail, Password = "******", Role = Role.Admin }; Helper.Users.Add(adminUser); } #endregion }
public static void Delete(User item) { try { var items = GetAll(); var itemToDelete = items.Where(p => p.Id == item.Id).FirstOrDefault(); items.Remove(itemToDelete); Add(items); } catch { } }
public static void Add(User item) { try { var items = GetAll(); if (items.Any(p => p.Id == item.Id || p.Username == item.Username || p.Email == item.Email)) return; items.Add(item); Add(items); } catch { } }
public static void Update(User item) { try { var items = GetAll(); var oldItem = items.Where(p => p.Id == item.Id).FirstOrDefault(); items.Remove(oldItem); items.Add(item); Add(items); } catch { } }