public HttpResponseMessage Post(AdminModel model) { if (AdminList.Any(p => p.UserName == model.UserName)) { return this.Request.CreateResponse(HttpStatusCode.Conflict, "User Name Already Exixt"); } AdminList.Add(model); return this.Request.CreateResponse(HttpStatusCode.Created); }
public MusicStoreBootStrap SeedDatabase() { var database = Database.Open(); database.AdminUser.DeleteAll(); database.Products.DeleteAll(); AdminModel adminUser = new AdminModel(); adminUser.UserName = "******"; adminUser.Password = "******"; database.AdminUser.Insert(adminUser); database.Products.Insert(new Product { Name = "Samsung s2", Id = 1, Categories = "Mobile", Price = 20000 }); database.Products.Insert(new Product { Name = "HTC sensation", Id = 2, Categories = "Mobile", Price = 30000 }); database.Products.Insert(new Product { Name = "Nokia lumia", Id = 3, Categories = "Mobile", Price = 10000 }); database.Products.Insert(new Product { Name = "sony experia", Id = 4, Categories = "Mobile", Price = 1000 }); database.Products.Insert(new Product { Name = "samsung series 9", Id = 5, Categories = "Laptop", Price = 30000.00 }); database.Products.Insert(new Product { Name = "Dell xps", Id = 6, Categories = "Laptop", Price = 40000.00 }); database.Products.Insert(new Product { Name = "HP envy", Id = 7, Categories = "Laptop", Price = 50000.00 }); database.Products.Insert(new Product { Name = "Sony vaio", Id = 8, Categories = "Laptop", Price = 60000.00 }); database.Products.Insert(new Product { Name = "Samsung Camera", Id = 9, Categories = "Camera", Price = 10000.00 }); database.Products.Insert(new Product { Name = "Sony", Id = 10, Categories = "Camera", Price = 11000.00 }); database.Products.Insert(new Product { Name = "Legend of Mehula", Id = 11, Categories = "Books", Price = 100.00 }); database.Products.Insert(new Product { Name = "2 States", Id = 12, Categories = "Books", Price = 100.00 }); database.Products.Insert(new Product { Name = "Router", Id = 13, Categories = "Home Accessories", Price = 1000.00 }); database.Products.Insert(new Product { Name = "Webcam", Id = 14, Categories = "Home Accessories", Price = 1000.00 }); database.Products.Insert(new Product { Name = "PenDrive", Id = 15, Categories = "Electronics", Price = 1000.00 }); database.Products.Insert(new Product { Name = "Electric Stove", Id = 16, Categories = "Kitchen", Price = 450.00 }); database.Products.Insert(new Product { Name = "Sony", Id = 17, Categories = "TV", Price = 25000.00 }); database.Products.Insert(new Product { Name = "LG", Id = 18, Categories = "TV", Price = 25000.00 }); return this; }