Пример #1
0
        private LunchOrder GetLunchOrderById(int intId)
        {
            LunchOrder lunchOrder = new LunchOrder();

            try
            {
                string         url       = "https://saibugasinformations-dev.outsystemsenterprise.com/LunchOrder_Core/rest/LunchOrder/GetLunchOrder";
                string         parameter = "?LunchOrderId=" + intId.ToString();
                HttpWebRequest WebReq    = (HttpWebRequest)WebRequest.Create(string.Format(url + parameter));

                WebReq.Method = "GET";

                HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();

                Console.WriteLine(WebResp.StatusCode);

                string jsonString;
                using (Stream stream = WebResp.GetResponseStream())   //modified from your code since the using statement disposes the stream automatically when done
                {
                    StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8);
                    jsonString = reader.ReadToEnd();
                }

                lunchOrder = JsonConvert.DeserializeObject <LunchOrder>(jsonString);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(lunchOrder);
        }
        public LunchOrder AddLunchOrder(Guid userId, Guid locationId, DateTime lunchDate)
        {
            if (lunchDate.Date < DateTimeOffset.Now.AddDays(2))
            {
                _logger.LogInformation("LunchOrder date does not meet 2 day in advance rule");
                throw new InvalidLunchOrderDateException();
            }

            var user     = _userRepository.GetById(userId);
            var location = _locationRepository.GetById(locationId);

            var lunchOrder = new LunchOrder
            {
                Id        = Guid.NewGuid(),
                CreatedAt = DateTimeOffset.Now,
                CreatedBy = user,
                Date      = lunchDate,
                Location  = location
            };

            _lunchOrderRepository.Add(lunchOrder);
            _logger.LogInformation("LunchOrder width id {id} is created", lunchOrder.Id);

            return(lunchOrder);
        }
Пример #3
0
        private LunchOrder GetLunchOrderById(int intId)
        {
            LunchOrder lunchOrder = new LunchOrder();

            try
            {
                HttpClient client = new HttpClient();

                client.BaseAddress = new Uri("https://saibugasinformations-dev.outsystemsenterprise.com/LunchOrder_Core/rest/LunchOrder/");

                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = client.GetAsync("GetLunchOrder?LunchOrderId=" + intId.ToString()).Result;

                if (response.IsSuccessStatusCode)
                {
                    lunchOrder = response.Content.ReadAsAsync <LunchOrder>().Result;
                }
                else
                {
                    MessageBox.Show("Error Code" + response.StatusCode + " : Message - " + response.ReasonPhrase);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(lunchOrder);
        }
Пример #4
0
        static void BuilderPatternTest()
        {
            LunchOrder.Builder builder = new LunchOrder.Builder();
            builder.AddBread("Taba Nan").AddDressing("Some Dressing").AddMeat("Hourse Meat");
            LunchOrder lunchOrder = new LunchOrder(builder);

            Console.WriteLine(lunchOrder.GetBread());
            Console.WriteLine(lunchOrder.GetDressing());
            Console.WriteLine(lunchOrder.GetMeat());
        }
Пример #5
0
        static void Main(string[] args)
        {
            var builder = new LunchOrder.Builder();

            LunchOrder order =
                builder.Bread("Wheat")
                .Dressing("Mayo")
                .Meat("Turkey")
                .GetLunchOrder();

            Console.WriteLine(order);
        }
Пример #6
0
        public void GetLunchOrderTest()
        {
            // arrange
            LunchOrder.Builder builder = new LunchOrder.Builder();

            // act
            LunchOrder order =
                builder.Bread("Wheat")
                .Dressing("Mayo")
                .Meat("Turkey")
                .GetLunchOrder();

            // assert
            Assert.AreEqual(order.Bread, "Wheat");
            Assert.AreEqual(order.Condiments, null);
            Assert.AreEqual(order.Dressing, "Mayo");
            Assert.AreEqual(order.Meat, "Turkey");
        }
    public void LunchOrderCreated(LunchOrder lunchOrder)
    {
        var foodIds = lunchOrder.Recipies().Select(r => r.Name);

        var foodChildren = transform.Children().Where(child => child.gameObject != bubbleGraphics);

        var childrenToActivate = foodChildren
            .Where(child => foodIds.Any(id => MatchingFoodIds(id, child.name)))
            .Concat(new []{ bubbleGraphics });

        var childrenToDeactivate = foodChildren.Except(childrenToActivate);

        foreach (Transform child in childrenToActivate)
        {
            child.gameObject.SetActive(true);
        }

        foreach(Transform child in childrenToDeactivate)
        {
            child.gameObject.SetActive(false);
        }
    }
Пример #8
0
        public LunchOrderDetail(LunchOrderManagement wndOrderMng, int passId)
        {
            InitializeComponent();

            this.wndOrderManagement = wndOrderMng;

            listLunchMenu                  = GetLunchMenu();
            ddlLunchMenu.ItemsSource       = listLunchMenu;
            ddlLunchMenu.DisplayMemberPath = "MenuName";
            ddlLunchMenu.SelectedValuePath = "Id";

            if (passId > 0)
            {
                Console.WriteLine(passId);

                lunchOrder = GetLunchOrderById(passId);

                if (lunchOrder != null)
                {
                    txtOrderId.Text            = lunchOrder.OrderId;
                    txtOrderPerson.Text        = lunchOrder.OrderPerson;
                    dtOrderDate.SelectedDate   = lunchOrder.OrderDate;
                    ddlLunchMenu.SelectedValue = lunchOrder.LunchMenuId;
                    txtQuantity.Text           = lunchOrder.Quantity.ToString();

                    LunchMenu menu = listLunchMenu.Find(x => x.Id == lunchOrder.LunchMenuId);
                    lblAmount.Content = "¥" + Math.Round(lunchOrder.Quantity * menu.Price, 2);

                    isNewOrder = false;
                }
                else
                {
                    this.Close();

                    MessageBox.Show("Lunch Order is not existed. Please check again.", "Read Data Failed");
                }
            }
        }
 public LunchOrder Add(LunchOrder entity)
 {
     _lunchOrders.Add(entity);
     return(entity);
 }
 public void LunchOrderCreated(LunchOrder lunchOrder)
 {
     TheLunchOrder = lunchOrder;
 }