public void GetOrder(OrderDomain order)
 {
     if (order.DishTypes.Where(x => x == DishType.Invalid).Count() > 0)
     {
         order.ErrorMessage = "Invalid Selection";
     }
 }
        public HttpResponseMessage UpdateTableCode(OrderAPIViewModel order)
        {
            var customerDomain = new CustomerDomain();
            BaseResponse <OrderHistoryAPIViewModel> response = new BaseResponse <OrderHistoryAPIViewModel>();
            HttpResponseMessage httpResponseMessage          = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK
            };
            var customerId = customerDomain.getCustomerIdFromToken(RequestContext);

            if (customerId != null)
            {
                order.CustomerID = customerId;
            }
            var domain = new OrderDomain();

            try
            {
                response = domain.UpdateTableCode(order, customerId.Value);
            }
            catch (ApiException e)
            {
                httpResponseMessage.StatusCode = e.StatusCode;
                response = BaseResponse <OrderHistoryAPIViewModel> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
                response = BaseResponse <OrderHistoryAPIViewModel> .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }
            httpResponseMessage.Content = new JsonContent(response);
            return(httpResponseMessage);
        }
        public IHttpActionResult Post(Order order)
        {
            var date = DateTime.Now;

            order.OrderDate = date;
            var message = OrderDomain.Post(order);

            if (message == "Order Placed")
            {
                var orderList = Uow.Repository <Order>().All();
                foreach (var item in orderList)
                {
                    if (item.UserId == order.UserId)
                    {
                        var dateDatabase   = (item.OrderDate).ToString("hh:mm:ss tt");
                        var dateController = date.ToString("hh:mm:ss tt");

                        if (dateDatabase == dateController)
                        {
                            return(Ok(new { message = message, data = item.OrderId }));
                        }
                    }
                }
                return(Ok("error"));
            }
            else
            {
                return(Ok(new { message = "order not placed" }));
            }
        }
 public void GetOrder(OrderDomain order)
 {
     if (order.DishTypes.Where(x => x == DishType.Dessert).Count() > 0)
     {
         order.ErrorMessage = "Invalid Order.";
     }
 }
Ejemplo n.º 5
0
        public string GenerateFormattedOutput(OrderDomain order)
        {
            StringBuilder formattedStringOutput = new StringBuilder();

            string prefix = "";

            foreach (var item in order.ReturnOrders)
            {
                formattedStringOutput.Append(prefix);
                prefix = ",";

                formattedStringOutput.Append(item.Value[0].ToLower());
                if (item.Value.Count() > 1)
                {
                    formattedStringOutput.Append(string.Format("(x{0})", item.Value.Count()));
                }
            }

            if (!string.IsNullOrWhiteSpace(order.ErrorMessage))
            {
                formattedStringOutput.Append(prefix);
                formattedStringOutput.Append("error");
            }

            return(formattedStringOutput.ToString());
        }
Ejemplo n.º 6
0
        public void ReceiveOrderWithInvalidTimeOfDay_ThrowsValidationException()
        {
            var order = "evening,1,1,1";

            var controller         = new OrderDomain(_apiOptions, order);
            ValidationException ex = Assert.Throws <ValidationException>(() => controller.ValidateOrderDomain());

            Assert.Equal("Invalid Time of Day", ex.Message);
        }
Ejemplo n.º 7
0
        public void ReceiveOrderWithInvalidFoodId_ThrowsValidationException()
        {
            var order = "morning,A";

            var controller         = new OrderDomain(_apiOptions, order);
            ValidationException ex = Assert.Throws <ValidationException>(() => controller.ValidateOrderDomain());

            Assert.Equal("Invalid Food Id", ex.Message);
        }
Ejemplo n.º 8
0
        public void ReceiveOrderWithoutFoodId_ReturnBlank()
        {
            var order = "morning";

            var controller = new OrderDomain(_apiOptions, order);

            controller.ValidateOrderDomain();
            var result = controller.ProcessOrder();

            Assert.Equal("", result);
        }
Ejemplo n.º 9
0
        public void ReceiveOrderAndProcessSuccessfully_ReturnResponse()
        {
            var order = "morning,1,1,1";

            var controller = new OrderDomain(_apiOptions, order);

            controller.ValidateOrderDomain();
            var result = controller.ProcessOrder();

            Assert.Equal("eggs(x3)", result);
        }
Ejemplo n.º 10
0
 public string Get(string order)
 {
     try
     {
         var orderDomain = new OrderDomain(_apiOptions, order);
         orderDomain.ValidateOrderDomain();
         return(orderDomain.ProcessOrder());
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
        public HttpResponseMessage GetHistoryOrder(OrderRequest <string> request)
        {
            BaseResponse <List <OrderHistoryAPIViewModel> > response = new BaseResponse <List <OrderHistoryAPIViewModel> >();
            var domain         = new OrderDomain();
            var customerDomain = new CustomerDomain();
            HttpResponseMessage httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK
            };
            var   customerId     = customerDomain.getCustomerIdFromToken(RequestContext);
            var   claimPrincipal = (ClaimsPrincipal)RequestContext.Principal;
            var   employeeId     = claimPrincipal.Claims.Where(c => c.Type == "EmployeeId").Select(c => c.Value).SingleOrDefault();
            var   userName       = claimPrincipal.Claims.Where(c => c.Type == "UserName").Select(c => c.Value).SingleOrDefault();
            Int32 employeeID     = 0;

            Int32.TryParse(employeeId, out employeeID);
            if (request.CreateAtMax.HasValue)
            {
                request.CreateAtMax = request.CreateAtMax.Value.GetEndOfDate();
            }
            if (request.CreateAtMin.HasValue)
            {
                request.CreateAtMin = request.CreateAtMin.Value.GetEndOfDate();
            }

            if (customerId != null)
            {
                request.CustomerId = customerId.Value;
            }
            if (employeeID != 0)
            {
                request.UserName = userName;
            }
            try
            {
                response = domain.GetOrderHistoryByRequest(request);
            }
            catch (ApiException e)
            {
                httpResponseMessage.StatusCode = e.StatusCode;
                response = BaseResponse <List <OrderHistoryAPIViewModel> > .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
                response = BaseResponse <List <OrderHistoryAPIViewModel> > .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }
            httpResponseMessage.Content = new JsonContent(response);
            return(httpResponseMessage);
        }
Ejemplo n.º 12
0
        public HttpResponseMessage CheckVoucher(CheckVoucherViewModel request)
        {
            //Logger.Log("Store " + model.terminalId);
            //Logger.Log("|CheckVoucherCode| begin method");
            var response       = new BaseResponse <dynamic>();
            var claimPrincipal = (ClaimsPrincipal)RequestContext.Principal;
            var customerId     = claimPrincipal.Claims.Where(c => c.Type == "CustomerId").Select(c => c.Value).SingleOrDefault();
            var cDomain        = new CustomerDomain();
            var id             = Int32.Parse(customerId);
            var customer       = cDomain.GetCustomerById(id);
            var oDomain        = new OrderDomain();

            var resp = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK
            };

            try
            {
                DateTime time    = DataService.Models.Utils.GetCurrentDateTime();
                var      pDomain = new PromotionDomain();
                var      orderVM = new OrderAPIViewModel();
                var      voucher = pDomain.GetVoucher(request.VoucherCode);
                var      mbs     = customer.MembershipVM;

                orderVM.OrderDetails = request.Data;
                orderVM.StoreID      = request.StoreId;
                AddInfo(orderVM, request);
                oDomain.CalculateOrderPrice(orderVM, time);

                //temp: each voucher has only 1 detail now
                var applyResult = pDomain.IsVoucherValidFor(voucher, orderVM, mbs);
                orderVM = pDomain.ApplyPromotionToOrder(orderVM, applyResult, mbs);

                response = BaseResponse <dynamic> .Get(true, "Thành công", orderVM, ResultEnum.Success);
            }
            catch (ApiException e)
            {
                resp.StatusCode = e.StatusCode;
                response        = BaseResponse <dynamic> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                resp.StatusCode = HttpStatusCode.InternalServerError;
                response        = BaseResponse <dynamic> .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }

            resp.Content = new JsonContent(response);
            return(resp);
        }
Ejemplo n.º 13
0
        public void GetOrder(OrderDomain order)
        {
            var drinkQuery = order.DishTypes.Where(x => x == DishType.Drink);

            if (drinkQuery.Count() > 0)
            {
                List <string> drinkItems = new List <string>();

                foreach (var dType in drinkQuery)
                {
                    drinkItems.Add(FoodItems.Coffee.ToString());
                }

                order.ReturnOrders.Add(DishType.Drink, drinkItems);
            }
        }
Ejemplo n.º 14
0
        public void GetOrder(OrderDomain order)
        {
            var sidesQuery = order.DishTypes.Where(x => x == DishType.Side);

            if (sidesQuery.Count() > 0)
            {
                List <string> sideItems = new List <string>();

                foreach (var dType in sidesQuery)
                {
                    sideItems.Add(FoodItems.Potato.ToString());
                }

                order.ReturnOrders.Add(DishType.Side, sideItems);
            }
        }
        public HttpResponseMessage CreateOrder(OrderAPIViewModel order)
        {
            var customerDomain = new CustomerDomain();
            BaseResponse <OrderHistoryAPIViewModel> response = new BaseResponse <OrderHistoryAPIViewModel>();
            HttpResponseMessage httpResponseMessage          = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK
            };

            #region get CustomerId and EmployeeId from Token
            var customerId = customerDomain.getCustomerIdFromToken(RequestContext);
            if (customerId != null)
            {
                order.CustomerID = customerId;
            }
            var   claimPrincipal = (ClaimsPrincipal)RequestContext.Principal;
            var   employeeId     = claimPrincipal.Claims.Where(c => c.Type == "EmployeeId").Select(c => c.Value).SingleOrDefault();
            var   userName       = claimPrincipal.Claims.Where(c => c.Type == "UserName").Select(c => c.Value).SingleOrDefault();
            Int32 employeeID     = 0;
            Int32.TryParse(employeeId, out employeeID);
            if (employeeID != 0)
            {
                order.EmployeeId    = employeeID;
                order.CheckInPerson = userName;
            }
            #endregion

            IOrderDomain domain = new OrderDomain();
            try
            {
                response = domain.AddOrderFromMobile(order);
            }
            catch (DataService.Utilities.ApiException e)
            {
                httpResponseMessage.StatusCode = e.StatusCode;
                response = BaseResponse <OrderHistoryAPIViewModel> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
                response = BaseResponse <OrderHistoryAPIViewModel> .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }
            httpResponseMessage.Content = new JsonContent(response);
            return(httpResponseMessage);
        }
Ejemplo n.º 16
0
        public string GetOrderOutput(string[] orderParams)
        {
            OrderDomain order = BuildOrder(orderParams);

            _rules = RulesEngine.GetRules(order);

            foreach (var rule in _rules)
            {
                rule.GetOrder(order);

                if (!string.IsNullOrWhiteSpace(order.ErrorMessage))
                {
                    break;
                }
            }

            var orderOutput = GenerateFormattedOutput(order);

            return(orderOutput);
        }
Ejemplo n.º 17
0
        private OrderDomain BuildOrder(string[] orderParams)
        {
            List <string> lstOrdParams = orderParams.ToList();

            OrderDomain inputOrder = new OrderDomain();

            TimeOfDay timeOfDay = (TimeOfDay)Enum.Parse(typeof(TimeOfDay), lstOrdParams[0].ToUpper());

            inputOrder.TimeOfDay = timeOfDay;
            inputOrder.DishTypes = new List <DishType>();

            if (string.IsNullOrWhiteSpace(lstOrdParams.Skip(1).Last().ToString()))
            {
                lstOrdParams.RemoveAt(lstOrdParams.Count() - 1);
            }

            foreach (var itemId in lstOrdParams.Skip(1))
            {
                DishType _dtype;
                int      intEnumValue;
                if (int.TryParse(itemId, out intEnumValue))
                {
                    if (Enum.IsDefined(typeof(DishType), intEnumValue))
                    {
                        _dtype = (DishType)(object)intEnumValue;
                    }
                    else
                    {
                        _dtype = DishType.Invalid;
                    }
                }
                else
                {
                    throw new InvalidCastException("Invalid selection.");
                }

                inputOrder.DishTypes.Add(_dtype);
            }

            return(inputOrder);
        }
Ejemplo n.º 18
0
        public void GetOrder(OrderDomain order)
        {
            List <string> drinkItems = new List <string>()
            {
                FoodItems.Wine.ToString()
            };

            foreach (var dType in order.DishTypes.Where(x => x == DishType.Drink))
            {
                var existingOrder = order.ReturnOrders.Where(x => x.Key == DishType.Drink);

                if (existingOrder.Count() > 1)
                {
                    order.ErrorMessage = "Can not order more than one Drink.";
                }
                else
                {
                    order.ReturnOrders.Add(dType, drinkItems);
                }
            }
        }
Ejemplo n.º 19
0
        public void GetOrder(OrderDomain order)
        {
            List <string> entreeItems = new List <string>()
            {
                FoodItems.Steak.ToString()
            };

            foreach (var dType in order.DishTypes.Where(x => x == DishType.Entree))
            {
                var existingOrder = order.ReturnOrders.Where(x => x.Key == DishType.Entree);

                if (existingOrder.Count() > 0)
                {
                    order.ErrorMessage = "Can not order more than one Entree.";
                }
                else
                {
                    order.ReturnOrders.Add(dType, entreeItems);
                }
            }
        }
        public HttpResponseMessage CalculateFeeDelivery(OrderAPIViewModel order)
        {
            var customerDomain = new CustomerDomain();
            BaseResponse <OrderAPIViewModel> response = new BaseResponse <OrderAPIViewModel>();
            HttpResponseMessage httpResponseMessage   = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK
            };
            //var customerId = customerDomain.getCustomerIdFromToken(RequestContext);
            //if (customerId != 0)
            //{
            //    order.CustomerID = customerId;
            //}
            IOrderDomain domain = new OrderDomain();

            try
            {
                var customerID = customerDomain.getCustomerIdFromToken(RequestContext);
                if (customerID != null)
                {
                    order.CustomerID = customerID;
                }
                response.Data       = domain.GetDeliveryFee(order);
                response.Message    = ConstantManager.MES_SUCCESS;
                response.ResultCode = (int)ResultEnum.Success;
                response.Success    = true;
            }
            catch (DataService.Utilities.ApiException e)
            {
                httpResponseMessage.StatusCode = e.StatusCode;
                response = BaseResponse <OrderAPIViewModel> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
                response = BaseResponse <OrderAPIViewModel> .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }
            httpResponseMessage.Content = new JsonContent(response);
            return(httpResponseMessage);
        }
Ejemplo n.º 21
0
        public static List <IOrderTypeRule> GetRules(OrderDomain order)
        {
            List <IOrderTypeRule> _rules = new List <IOrderTypeRule>();

            if (order.TimeOfDay == TimeOfDay.MORNING)
            {
                _rules.Add(new MorningEntreeRule());
                _rules.Add(new MorningSideRule());
                _rules.Add(new MorningDrinkRule());
                _rules.Add(new MorningDessertRule());
            }
            else
            {
                _rules.Add(new NightEntreeRule());
                _rules.Add(new NightSideRule());
                _rules.Add(new NightDrinkRule());
                _rules.Add(new NightDessertRule());
            }

            _rules.Add(new InvalidSelectionRule());

            return(_rules);
        }
        public IHttpActionResult Post(OrderDetailsModel orderDetail)
        {
            if (orderDetail.PaymentTypeId == 33)
            {
                var encryption = Encrypt((orderDetail.CardNumber).ToString(), true);
                var card       = Uow.Repository <Card>().FirstOrDefault(c => (c.CardNumber == encryption) && (c.Cvv == orderDetail.CVV));
                if (card != null)
                {
                    if (card.Amount >= orderDetail.Amount)
                    {
                        var cartList = Uow.Repository <Cart>().All();
                        if (cartList != null)
                        {
                            string             message;
                            int                flag            = 0;
                            List <OrderDetail> orderDetailList = new List <OrderDetail>();
                            foreach (var item in cartList)
                            {
                                if (item.UserId == orderDetail.UserId)
                                {
                                    OrderDetail detailTemp = new OrderDetail();
                                    detailTemp.ProductId = item.ProductId;
                                    detailTemp.Quantity  = item.Quantity;
                                    detailTemp.SubTotal  = item.SubTotal;
                                    var product = Uow.Repository <Product>().FirstOrDefault(p => p.ProductId == item.ProductId);
                                    detailTemp.DiscountId = product.DiscountId;
                                    detailTemp.OrderId    = orderDetail.OrderId;
                                    orderDetailList.Add(detailTemp);
                                }
                            }

                            if (orderDetailList != null)
                            {
                                try
                                {
                                    message = (OrderDetailDomain.Post(orderDetailList));
                                    if (message != "Order Placed!!")
                                    {
                                        flag = 1;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    throw ex;
                                }
                            }

                            if (flag != 1)
                            {
                                var Order = Uow.Repository <Order>().FirstOrDefault(o => o.OrderId == orderDetail.OrderId);
                                Order.OrderStatus   = "true";
                                Order.PaymentTypeId = orderDetail.PaymentTypeId;
                                OrderDomain.Put(Order);
                                card.Amount = card.Amount - orderDetail.Amount;
                                CardDomain.Put(card);
                                return(Ok("items ordered"));
                            }
                            else
                            {
                                return(Ok("Order Not Placed!"));
                            }
                        }
                        else
                        {
                            return(Ok("cart is empty"));
                        }
                    }

                    else
                    {
                        return(Ok("Insufficient amount in card"));
                    }
                }
                else
                {
                    return(Ok());
                }
            }
            else if (orderDetail.PaymentTypeId == 34)
            {
                var balanceCheck = BalanceDomain.GetBy(orderDetail.UserId);
                if (balanceCheck.BalanceAmount >= orderDetail.Amount)
                {
                    balanceCheck.BalanceAmount = balanceCheck.BalanceAmount - orderDetail.Amount;
                    var message = BalanceDomain.Put(balanceCheck);
                    if (message == "Item Updated.")
                    {
                        return(Ok("items ordered"));
                    }
                    else
                    {
                        return(Ok());
                    }
                }
                else
                {
                    return(Ok("balance is not enough"));
                }
            }
            else
            {
                return(Ok("error"));
            }
        }
Ejemplo n.º 23
0
 private static bool BaseEquals(OrderDomain oo, OrderEf dto)
 {
     return(oo.Id == dto.Id);
 }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            bool           carryon = true;
            char           ch;
            int            i;
            OrderDomain    orderDomain    = new OrderDomain();
            CustomerDomain customerDomain = new CustomerDomain();
            CompanyDomain  companyDomain  = new CompanyDomain();

            Console.WriteLine("----------------Welcome in ToySelling Application-------------");
            while (carryon)
            {
                Console.WriteLine("\n1. Customer Registration\t2.Company Registration\n3. Add Toy In Production\t 4. View Toys\n5. View Customers \n6 . Add Shipping Address\t7. Show Address \n 8. Add Order In Cart\t9. View Cart Order  \n10. Place Order \t 11. View Invoice\n\nEnter Your Choice : ");
                int choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    Customer customer = new Customer();
                    Console.WriteLine("\nEnter Name :");
                    customer.Name = Console.ReadLine();
                    Console.WriteLine("\nEnter Mobile No :");
                    customer.MobileNo = Convert.ToInt32(Console.ReadLine()).ToString();
                    Console.WriteLine("\nEnter City :");
                    customer.City = Console.ReadLine();

                    customerDomain.AddCustomer(customer);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                case 2:
                    Company company = new Company();
                    Console.WriteLine("\nEnter Name :");
                    company.CompanyName = Console.ReadLine();
                    Console.WriteLine("\nEnter City :");
                    company.City = Console.ReadLine();

                    companyDomain.AddCompany(company);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                case 3:
                    ToyProduction toyProduction = new ToyProduction();
                    Console.WriteLine("\nEnter Toy Id :");
                    toyProduction.ToyId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter CompanyId :");
                    toyProduction.CompanyId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Price :");
                    toyProduction.Price = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Quantity :");
                    toyProduction.Quantity = Convert.ToInt32(Console.ReadLine());
                    CompanyDomain companyDomain1 = new CompanyDomain();
                    companyDomain1.AddToyProduction(toyProduction);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                case 4:
                    CompanyDomain cd = new CompanyDomain();
                    i = 1;
                    foreach (ToyProduction toy in cd.GetToyProduction())
                    {
                        Console.WriteLine("Toy - " + i);
                        Console.WriteLine("ToyProductionId : " + toy.ProductionId);
                        Console.WriteLine("ToyId : " + toy.ToyId);
                        Console.WriteLine("CompanyId : " + toy.CompanyId);
                        Console.WriteLine("Price : " + toy.Price);
                        Console.WriteLine("Total Toy : " + toy.Quantity);
                        Console.WriteLine("------------------------------------------------");
                    }
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 5:
                    foreach (Customer customer1 in customerDomain.GetCustomers())
                    {
                        Console.WriteLine("Customer Id : " + customer1.CustomerId);
                        Console.WriteLine("Name : " + customer1.Name);
                        Console.WriteLine("Mobile No : " + customer1.MobileNo);
                        Console.WriteLine("Ciry : " + customer1.City);
                        Console.WriteLine("------------------------------------------------");
                    }
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 6:
                    CustomerAddress customerAddress = new CustomerAddress();
                    Console.WriteLine("\nEnter Address :");
                    customerAddress.Address = Console.ReadLine();
                    Console.WriteLine("\nEnter Custermer Id :");
                    customerAddress.CustomerId = Convert.ToInt32(Console.ReadLine());
                    CustomerDomain cust = new CustomerDomain();
                    cust.AddAddress(customerAddress);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 7:
                    CustomerAddress ca = new CustomerAddress();
                    Console.WriteLine("Enter Customer Id :");
                    ca.CustomerId = Convert.ToInt32(Console.ReadLine());
                    foreach (CustomerAddress customer1 in customerDomain.GetCustomerAddresses(ca))
                    {
                        Console.WriteLine("Customer Id : " + customer1.CustomerId);
                        Console.WriteLine("Address Id : " + customer1.AddressId);
                        Console.WriteLine("Address : " + customer1.Address);
                        Console.WriteLine("------------------------------------------------");
                    }
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 8:
                    Order order = new Order();
                    Console.WriteLine("\nEnter Custermer Id :");
                    order.CustomerId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter ToyProduction Id :");
                    order.ProductionId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Quantity :");
                    order.Quantity = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Shipping Address Id :");
                    order.AddressId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Order Date :");
                    order.OrderDate = Convert.ToDateTime(Console.ReadLine());

                    orderDomain.AddOrder(order);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 9:
                    foreach (Order orders in orderDomain.GetOrders())
                    {
                        Console.WriteLine("Order Id : " + orders.OderId);
                        Console.WriteLine("ToyId : " + orders.CustomerId);
                        Console.WriteLine("ToyId : " + orders.ProductionId);
                        Console.WriteLine("AddressId : " + orders.AddressId);
                        Console.WriteLine("------------------------------------------------");
                    }
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 10:
                    orderDomain.GetOrderById();
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                case 11:
                    Invoice invoice = new Invoice();
                    invoice = orderDomain.GetInvoiceById();
                    Console.WriteLine("Invoice Id :" + invoice.InvoiceId);
                    Console.WriteLine("Order Id :" + invoice.OrderId);
                    Console.WriteLine("Price :" + invoice.Price);
                    Console.WriteLine("Offer Id :" + invoice.OfferId);
                    Console.WriteLine("Final Price :" + invoice.FinalPrice);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                default:
                    carryon = false;
                    break;
                }
            }
        }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            Customer       customer20     = new Customer();
            Plant          plant10        = new Plant();
            ToyDomain      toyDomain      = new ToyDomain();
            PlantDomain    plantDomain    = new PlantDomain();
            ToyType        toyType10      = new ToyType();
            Customer       customer       = new Customer();
            ToyTypeDomain  toyTypeDomain  = new ToyTypeDomain();
            CustomerDomain customerDomain = new CustomerDomain();
            OrderDomain    orderDomain    = new OrderDomain();

repeate:
            Console.WriteLine("--->>Welcome to Toy Store application<<---");

            Console.WriteLine("-->>Choose form the below given options<<--");

            Console.WriteLine("=1.1:->Enter ToyType..{this option adds which type of toy you Manufacturing}");
            Console.WriteLine("=1.2:->Show list of ToyTypes..{this option shows whole list of entered ToyTypes}");
            Console.WriteLine("=1.3:->Delete ToyType..{this option deletes selected field}");
            Console.WriteLine("=2.1:->Enter Plant..{this option adds the information regarding to the Manufacturing Plants}");
            Console.WriteLine("=2.2:->Show  list of Plants..{this option shows list of Manufacturing Plants}");
            Console.WriteLine("=2.3:->Delete Plant..{this option deletes Manufacturing plants}");
            Console.WriteLine("=3.1:->Enter Customer..{this option adds the information regarding to Customer}");
            Console.WriteLine("=3.2:->Show list of Customers..{this option shows list of Customers}");
            Console.WriteLine("=3.3:->Delete Customer..{this option deletes Customers}");
            Console.WriteLine("=4.1:->Enter Toys..{this option adds information regarding to the Toys}");
            Console.WriteLine("=4.2:->Show list of Toys..{this option shows the list of enterd Toys}");
            Console.WriteLine("=5.1:->Enter Order..{this option adds order details}");
            Console.WriteLine("=5.2:->Show list of Orders..{this option shows the list of enterd Orders}");
            Console.WriteLine("Enter any other numeric key to Exit the program");
            double c = double.Parse(Console.ReadLine());

            switch (c)
            {
            case 1.1:
                toyTypeDomain.AddToyType();
                Console.WriteLine("");
                goto repeate;

            case 1.2:
                Console.WriteLine("Id\t ToyType");
                foreach (ToyType toyType in toyTypeDomain.GetToyType())
                {
                    Console.WriteLine($"{toyType.ToyTypeId}\t  {toyType.ToyTypeName}");
                }
                Console.WriteLine("");
                goto repeate;

            case 1.3:
                Console.WriteLine("--->>Delete ToyType<<---");
                Console.WriteLine("Enter typeId");
                toyType10.ToyTypeId = Int32.Parse(Console.ReadLine());
                toyTypeDomain.DeleteToyType(toyType10);
                Console.WriteLine("");
                goto repeate;

            case 2.1:
                plantDomain.AddPlant();
                Console.WriteLine("");
                goto repeate;

            case 2.2:
                Console.WriteLine("Id\tPlantName PlantAddress");
                foreach (Plant plant in plantDomain.GetAllPlant())
                {
                    Console.WriteLine($"{plant.PlantId}\t{plant.PlantName}\t\t{plant.PlantAddress}");
                }
                Console.WriteLine("");
                goto repeate;

            case 2.3:
                Console.WriteLine("--->> Delete Plant <<---");
                Console.WriteLine("Enter Id To delete Plant: ");
                plant10.PlantId = Int32.Parse(Console.ReadLine());
                plantDomain.DeletePlant(plant10);
                Console.WriteLine("");
                goto repeate;

            case 3.1:
                customerDomain.AddCustomer();
                Console.WriteLine("");
                goto repeate;

            case 3.2:
                Console.WriteLine("\n--->> View All Customers <<---");

                Console.WriteLine("Id \t CustomerName \t CustomerAddress");
                foreach (Customer customer1 in customerDomain.GetAllCustomers())
                {
                    Console.WriteLine($"{customer1.CustomerId}\t  {customer1.CustomerName}\t\t{customer1.CustomerPermanentAddress} ");
                }
                Console.WriteLine("");
                goto repeate;

            case 3.3:
                Console.WriteLine("--->> Delete Plant <<---");
                Console.WriteLine("Enter Id To delete Plant: ");
                customer20.CustomerId = Int32.Parse(Console.ReadLine());
                customerDomain.DeleteCustomer(customer20);
                Console.WriteLine("");
                goto repeate;

            case 4.1:
                toyDomain.AddToy();
                Console.WriteLine("");
                goto repeate;

            case 4.2:
                Console.WriteLine("\n--->> View All Toys <<---");

                Console.WriteLine("Id \t ToyPrice\tToyTypeId\tPlantId");
                foreach (Toy toy in toyDomain.GetAllToy())
                {
                    Console.WriteLine($"{toy.ToyId}\t  {toy.ToyPrice}\t\t{toy.ToyTypeId}\t\t{toy.PlantId} ");
                }
                Console.WriteLine("");
                goto repeate;

            case 5.1:
                orderDomain.AddOrder();
                Console.WriteLine("");
                goto repeate;

            case 5.2:
                Console.WriteLine("\n--->> View All Orders <<---");

                Console.WriteLine("Id \tQuantity\tAddress\tDiscount\tToyId\tCustomerId");
                foreach (Order order in orderDomain.GetAllOrders())
                {
                    Console.WriteLine($"{order.OrderId}\t{order.OrderQuantity}\t\t{order.OrderAddress}\t{order.OrderDiscount}\t\t{order.ToyId}\t\t{order.CustomerId} ");
                }
                Console.WriteLine("");
                goto repeate;

            default:
                break;
            }

            /* customerDomain.AddCustomer();*/

            /*Console.WriteLine("\n--->> View All Customers <<---");
             *
             * Console.WriteLine("Id \t CustomerName \t CustomerAddress");
             * foreach (Customer customer1 in customerDomain.GetAllCustomers())
             * {
             *
             *  Console.WriteLine($"{customer1.CustomerId}\t  {customer1.CustomerName}\t\t{customer1.CustomerPermanentAddress} ");
             * }
             *
             *
             * Console.WriteLine("--->> Delete Customer <<---");
             * Console.WriteLine("Enter Id To delete Customer: ");
             * customer.CustomerId = Int32.Parse(Console.ReadLine());
             *
             *
             * Console.WriteLine("Hello World!");
             * Console.ReadLine();*/

            /*toyTypeDomain.AddToyType();*/

            /*Console.Writeline("Delete ToyType");
             * Console.WriteLine("Enter typeId");
             * toyType.ToyTypeId = Int32.Parse(Console.ReadLine());
             * toyTypeDomain.DeleteToyType(toyType);*/

            /*toyDomain.AddToy();*/

            /*Console.WriteLine("\n--->> View All Toys <<---");
             *
             * Console.WriteLine("Id \t ToyPrice\tToyTypeId\tPlantId" );
             * foreach (Toy toy in toyDomain.GetAllToy())
             * {
             *  Console.WriteLine($"{toy.ToyId}\t  {toy.ToyPrice}\t\t{toy.ToyTypeId}\t\t{toy.PlantId} ");
             * }*/


            //orderDomain.AddOrder();

            /*Console.WriteLine("\n--->> View All Orders <<---");
             *
             * Console.WriteLine("Id \tQuantity\tAddress\tDiscount\tToyId\tCustomerId");
             * foreach (Order order in orderDomain.GetAllOrders())
             * {
             *  Console.WriteLine($"{order.OrderId}\t{order.OrderQuantity}\t\t{order.OrderAddress}\t{order.OrderDiscount}\t\t{order.ToyId}\t\t{order.CustomerId} ");
             * }*/
        }