Пример #1
0
 public static void UpdatePastry(Pastery PastryToUpdate)
 {
     //using (var Contexts.DB = new PastryContext())
     {
         Contexts.DB.Pastries.AddOrUpdate(PastryToUpdate);
         int num = Contexts.DB.SaveChanges();
     }
 }
Пример #2
0
        public void CreatePasteryOrder_PasteryRegInt_Int()
        {
            //Arrange
            int input = 4;
            //Act
            Pastery newOrder = new Pastery(input);

            //Assert
            Assert.AreEqual(typeof(Pastery), newOrder.GetType());
        }
Пример #3
0
        public static int AddNewPastry(Pastery NewPastry)
        {
            //using (PastryContext db = new PastryContext())
            //{
            Contexts.DB.Pastries.Add(NewPastry);
            Contexts.DB.SaveChanges();

            return(NewPastry.ID);
            //}
        }
Пример #4
0
        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();
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
        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 }));
        }
Пример #7
0
        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"));
            }
        }
Пример #8
0
    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!");
    }
Пример #9
0
    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();
        }
    }