public void Create(string name, decimal price, string imageUrl) { using (var db = new ByTheCakeDbContext()) { var product = new Product(name, price, imageUrl); db.Add(product); db.SaveChanges(); } }
public void Create(string name, decimal price, string imageUrl) { using (var context = new ByTheCakeDbContext()) { var product = new Product { Name = name, Price = price, ImageUrl = imageUrl }; context.Add(product); context.SaveChanges(); } }
public void Create(string name, decimal price, string imageUrl) { using (var db = new ByTheCakeDbContext()) { var product = new Data.Models.Product() { Name = name, Price = price, ImageUrl = imageUrl }; db.Add(product); db.SaveChanges(); } }
public bool Create(string username, string password) { using (var db = new ByTheCakeDbContext()) { if (db.Users.Any(u => u.Username == username)) { return(false); } var user = new User(username, password, DateTime.UtcNow); db.Add(user); db.SaveChanges(); return(true); } }
public void CreateOrder(int userId, IEnumerable <int> productIds) { using (var db = new ByTheCakeDbContext()) { var order = new Order { UserId = userId, CreationDate = DateTime.UtcNow, Products = productIds.Select(id => new OrderProduct { ProductId = id }).ToList() }; db.Add(order); db.SaveChanges(); } }
public bool Create(string username, string password) { using (var db = new ByTheCakeDbContext()) { if (db.Users.Any(u => u.Username == username)) { return(false); } User user = new User { Username = username, Password = password, RegistrationDate = DateTime.UtcNow }; db.Add(user); db.SaveChanges(); return(true); } }
public void CreateOrder(int userId, Dictionary <int, int> products) { using (var db = new ByTheCakeDbContext()) { var order = new Order { UserId = userId, CreationTime = DateTime.UtcNow, Products = products.Keys.Select(id => new OrderProduct { ProductId = id, Quantity = products[id] }).ToList() }; db.Add(order); db.SaveChanges(); } }
public bool Success() { using (var db = new ByTheCakeDbContext()) { if (db.Users.Any(x => x.Username == username)) { return(false); } var user = new User(); user.Username = username; password = BCrypt.Net.BCrypt.HashPassword(password); user.Password = password; user.DateOfRegistration = DateTime.UtcNow; db.Add(user); db.SaveChanges(); return(true); } }
public bool Create(string name, string username, string password) { using (var context = new ByTheCakeDbContext()) { if (context.Users.Any(u => u.Username == username)) { return(false); } var user = new User { Name = name, Username = username, Password = PasswordUtilities.ComputeHash(password), RegistrationDate = DateTime.UtcNow }; context.Add(user); context.SaveChanges(); return(true); } }
public bool Create(string username, string password) { using (var context = new ByTheCakeDbContext()) { // Check is username already exists if (context.Users.Any(u => u.Username == username)) { return(false); } // Add User var user = new User { Username = username, Password = password, RegistrationDate = DateTime.UtcNow }; context.Add(user); context.SaveChanges(); return(true); } }