public static void UpdatePastry(Pastery PastryToUpdate) { //using (var Contexts.DB = new PastryContext()) { Contexts.DB.Pastries.AddOrUpdate(PastryToUpdate); int num = Contexts.DB.SaveChanges(); } }
public void CreatePasteryOrder_PasteryRegInt_Int() { //Arrange int input = 4; //Act Pastery newOrder = new Pastery(input); //Assert Assert.AreEqual(typeof(Pastery), newOrder.GetType()); }
public static int AddNewPastry(Pastery NewPastry) { //using (PastryContext db = new PastryContext()) //{ Contexts.DB.Pastries.Add(NewPastry); Contexts.DB.SaveChanges(); return(NewPastry.ID); //} }
public static void DeletePastry(Pastery PastryToRemove) { //using (PastryContext Contexts.DB = new PastryContext()) { var pastry = GetPatry(PastryToRemove.ID); OrderdDAL.DeleteAllRelatedDetails(pastry.OrdersDetailes); Contexts.DB.Entry(pastry).State = EntityState.Deleted; int num = Contexts.DB.SaveChanges(); } }
public void getInput_PastrySale_Int() { //Arrange int input = 4; int result = 7; Pastery newOrder = new Pastery(input); //Act int sale = newOrder.PasterySale(); //Assert Assert.AreEqual(result, sale); }
public ActionResult Save(FormCollection collection) { var model = new Pastery(); try { UpdateModel(model); Repository.DAL.PastryDAL.UpdatePastry(model); } catch (Exception e) { } return(RedirectToAction("View", new { id = model.ID })); }
public ActionResult Create(FormCollection collection) { var model = new Pastery(); try { TryUpdateModel(model, collection); int id = Repository.DAL.PastryDAL.AddNewPastry(model); return(RedirectToAction("View", new { id = id })); } catch (Exception e) { return(RedirectToAction("Create")); } }
public static void Main() { Console.WriteLine("Welcome to Pierre's Bakery! Fresh baked hourly, we offer loaves of bread and various pasteries for up to $5.00 USD each plus sales tax."); Console.WriteLine("How many loaves of bread would you like to purchase?"); int itemsBread = int.Parse(Console.ReadLine()); Bread breadOrder = new Bread(itemsBread); int finalBreadCosts = breadOrder.BreadCosts(); Console.WriteLine("How many pasteries woud you like to purchase?"); int itemsPastery = int.Parse(Console.ReadLine()); Pastery pasteryOrder = new Pastery(itemsPastery); int finalPasteryCosts = pasteryOrder.PasteryCosts(); int totalBalance = finalBreadCosts + finalPasteryCosts; Console.WriteLine("The total of your balance due is: $" + totalBalance + " USD. Thank you very much for supporting our business!"); }
static void Main() { Console.WriteLine("WELCOME TO TASTY BAKERY"); Console.WriteLine("--------------------"); Console.WriteLine("Price of Single Loaf of bread is $5 and Pastery is $2"); Console.WriteLine("--------------------"); Console.WriteLine("Offer Price: Buy 2 Get 1 Bread free"); Console.WriteLine("--------------------"); Console.WriteLine("How many loafs of bread you want?"); string OrderQuantity = Console.ReadLine(); Console.WriteLine("How many pasteries you want?"); string OrderQuantityTwo = Console.ReadLine(); Regex regex = new Regex("^[0-9]+$"); Match wordMatch = regex.Match(OrderQuantity); Match sentenceMatch = regex.Match(OrderQuantityTwo); if (wordMatch.Success && sentenceMatch.Success) { int OrderNumber = int.Parse(OrderQuantity); Bread newBread = new Bread(OrderNumber); int breadPrice = newBread.DecidePrice(); int breadDiscount = newBread.CalculateDiscount(); int OrderNumberPastery = int.Parse(OrderQuantityTwo); Pastery newPastery = new Pastery(OrderNumberPastery); int pasteryPrice = newPastery.DecidePasteryPrice(); Console.WriteLine($"Your total Order Price is {breadDiscount + pasteryPrice}"); } else { Console.WriteLine("------------"); Console.WriteLine("INVALID INPUT"); Main(); } }