예제 #1
0
        public ActionResult Dashboard()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Home"));
            }

            DashboardView dashboardView = new DashboardView();

            ViewBag.OutstandingTasks    = 0;
            ViewBag.OutstandingActions  = 0;
            ViewBag.OutstandingOffers   = 0;
            ViewBag.Orders              = 0;
            ViewBag.CurrentRequests     = 0;
            ViewBag.CurrentAvailable    = 0;
            ViewBag.RequestsOutstanding = 0;
            ViewBag.RequestsFulfilled   = 0;
            ViewBag.RequestsTotal       = 0;

            if (User.Identity.IsAuthenticated)
            {
                dashboardView = DashboardHelpers.GetDashboardViewLogin(User);
                ViewBag.OutstandingActions = UserActionHelpers.GetActionsForUser(User).Count();
                if (dashboardView.UserTaskList != null)
                {
                    ViewBag.OutstandingTasks = dashboardView.UserTaskList.Count();
                }
                if (dashboardView.RequirementListingList != null)
                {
                    ViewBag.CurrentRequests     = dashboardView.RequirementListingList.Count();
                    ViewBag.RequestsOutstanding = DashboardHelpers.GetRequirementsOutstandingFromDashboardView(dashboardView);
                    ViewBag.RequestsFulfilled   = DashboardHelpers.GetRequirementsFulfilledFromDashboardView(dashboardView);
                    ViewBag.RequestsTotal       = DashboardHelpers.GetRequirementsTotalFromDashboardView(dashboardView);
                }
                if (dashboardView.AvailableListingList != null)
                {
                    ViewBag.CurrentAvailable     = dashboardView.AvailableListingList.Count();
                    ViewBag.AvailableOutstanding = DashboardHelpers.GetAvailableOutstandingFromDashboardView(dashboardView);
                    ViewBag.AvailableFulfilled   = DashboardHelpers.GetAvailableFulfilledFromDashboardView(dashboardView);
                    ViewBag.AvailableTotal       = DashboardHelpers.GetAvailableTotalFromDashboardView(dashboardView);
                }
                if (dashboardView.OfferList != null)
                {
                    ViewBag.OutstandingOffers = dashboardView.OfferList.Count();
                }
                if (dashboardView.OrderList != null)
                {
                    ViewBag.Orders = dashboardView.OrderList.Count();
                }
            }
            else
            {
                dashboardView = DashboardHelpers.GetDashboardView();
            }

            return(View(dashboardView));
        }
예제 #2
0
        private void Confirm_Click(object sender, EventArgs e)
        {
            List <(bool, string)> validators = new List <(bool, string)>()
            {
                DataValidationManager.CheckEmail(EmailTextBox.Text),
                DataValidationManager.CheckFirstName(FirstNameTextBox.Text),
                DataValidationManager.CheckLastName(LastNameTextBox.Text),
                DataValidationManager.CheckAddress(AddressTextBox.Text),
            };

            foreach (var validator in validators)
            {
                if (!string.IsNullOrEmpty(validator.Item2))
                {
                    MessageBox.Show(validator.Item2, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }
            }

            if (validators.TrueForAll(x => x.Item1))
            {
                var emailBody = string.Format(emailBodyFormat, AddressTextBox.Text, FirstNameTextBox.Text, LastNameTextBox.Text, NotesTextBox.Text);

                EmailSendStatus emailSendStatus = new EmailManager().SendEmail(EmailTextBox.Text, "Pizza Application Order", emailBody);

                if (emailSendStatus.SendSuccessfully)
                {
                    MessageBox.Show(UserMessages.EmailSended, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    AddHistoryRecordToDatabase();
                    UserActionHelpers.ClearAllTextBoxData();
                    Hide();
                    WindowsManagement.GetMainWindowInstance().Show();
                }
                else
                {
                    MessageBox.Show(UserMessages.EmailFailedToSend, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
예제 #3
0
        private void AddExtrasProductToOrderList()
        {
            OrderWindow     orderWindow = WindowsManagement.GetOrderWindowInstance();
            TextBox         foodTextBox = orderWindow.choosedCountBox;
            List <CheckBox> checkBoxes  = new List <CheckBox>()
            {
                DoubleCheeseCheckbox,
                HamCheckbox,
                MushroomsCheckbox,
                SalamiCheckbox
            };

            string foodName = foodTextBox.Name.Replace("CountBox", string.Empty);

            ProductsConfiguration.ExtrasProduct.TryGetValue(foodName, out Product value);
            var order = new Order(new Product(value.Name, value.Price, value.Extras));

            List <string> extras = new List <string>();

            foreach (CheckBox checkBox in checkBoxes)
            {
                if (checkBox.Checked)
                {
                    checkBox.Checked = false;
                    extras.Add(checkBox.Text);
                    order.Product.Price += 2;
                }
            }

            if (extras.Any())
            {
                order.Product.Extras.Add(extras.Aggregate((i, j) => string.Format("{0}, {1}", i, j)));
            }

            orderWindow.orderList.Add(order);
            UserActionHelpers.AddValueToCountBox(foodTextBox);
            Hide();
            orderWindow.Show();
        }
예제 #4
0
 private void VegeterianaMinus_Click(object sender, EventArgs e)
 {
     UserActionHelpers.RemoveLastItemFromOrderListByName(ProductsNames.Vegetariana);
     UserActionHelpers.SubstractValuInCountBox(VegetarianaCountBox);
 }
예제 #5
0
 private void MargherittaMinus_Click(object sender, EventArgs e)
 {
     UserActionHelpers.RemoveLastItemFromOrderListByName(ProductsNames.Margheritta);
     UserActionHelpers.SubstractValuInCountBox(MargherittaCountBox);
 }
예제 #6
0
 private void BackButton_Click(object sender, EventArgs e)
 {
     Hide();
     WindowsManagement.GetMainWindowInstance().Show();
     UserActionHelpers.ClearAllTextBoxData();
 }
예제 #7
0
 private void ColaPlus_Click(object sender, EventArgs e)
 {
     orderList.Add(new Order(new Product(ProductsConfiguration.Product.TryGetValue(ProductsNames.Cola, out Product product) ? product.Name : string.Empty, product.Price)));
     UserActionHelpers.AddValueToCountBox(ColaCountBox);
 }
예제 #8
0
 private void CoffieMinus_Click(object sender, EventArgs e)
 {
     UserActionHelpers.RemoveLastItemFromOrderListByName(ProductsNames.Cola);
     UserActionHelpers.SubstractValuInCountBox(CoffieCountBox);
 }
예제 #9
0
 private void TomatoSoupMinus_Click(object sender, EventArgs e)
 {
     UserActionHelpers.RemoveLastItemFromOrderListByName(ProductsNames.TomatoSoup);
     UserActionHelpers.SubstractValuInCountBox(TomatoSoupCountBox);
 }
예제 #10
0
 private void HungarianCakeMinus_Click(object sender, EventArgs e)
 {
     UserActionHelpers.RemoveLastItemFromOrderListByName(ProductsNames.HungarianCake);
     UserActionHelpers.SubstractValuInCountBox(HungarianCountBox);
 }
예제 #11
0
 private void FishMinus_Click(object sender, EventArgs e)
 {
     UserActionHelpers.RemoveLastItemFromOrderListByName(ProductsNames.FishFries);
     UserActionHelpers.SubstractValuInCountBox(FishCountBox);
 }