public bool Create(string username, string email, string firstname, string lastName, string password) { using (var db = new ArtStoreDbContext()) { if (db.Users.Any(u => u.Username == username)) { return(false); } var isAdmin = !db.Users.Any(); var user = new User { Username = username, Email = email, FirstName = firstname, LastName = lastName, Password = password, IsAdmin = isAdmin }; db.Add(user); db.SaveChanges(); } return(true); }
public bool Create(string name, string description, int ownerId) { using (var db = new ArtStoreDbContext()) { var shop = new Shop { Name = name, Description = description, OwnerId = ownerId }; db.Add(shop); db.SaveChanges(); } return(true); }
public bool Create(string title, string description, decimal price, int sellerId) { using (var db = new ArtStoreDbContext()) { var item = new ItemForSale { Title = title, Description = description, Price = price, SellerId = sellerId, DateCreated = DateTime.Now }; db.Add(item); db.SaveChanges(); } return(true); }