public Sale(Vendor vendor, int productId, Supermarket supermarket, decimal unitPrice, int quantity) { this.vendor = vendor; this.ProductId = productId; this.supermarket = supermarket; this.UnitPrice = unitPrice; this.Quantity = quantity; this.Sum = this.Quantity * this.UnitPrice; this.Date = DateTime.Now; }
private Supermarket CheckSupermarketExist(string supermarketName, MsSqlEntities context) { var supermarket = context.Supermarkets.FirstOrDefault(s => s.Name == supermarketName); if (supermarket == null) { // TODO: Add new supermarket from report. supermarket = new Supermarket { Name = supermarketName }; context.Supermarkets.Add(supermarket); context.SaveChanges(); } return supermarket; }