public void CollectionOrdered_Comparer_Descending()
        {
            var constraint = Ordered.Using(ObjectComparer.Default).Descending;

            Expect(constraint, TypeOf <CollectionOrderedConstraint>());
            Expect(constraint.ToString(), EqualTo("<ordered descending NUnit.TestUtilities.Comparers.ObjectComparer>"));
        }
        public void CollectionOrderedBy()
        {
            var constraint = Ordered.By("SomePropertyName");

            Expect(constraint, TypeOf <CollectionOrderedConstraint>());
            Expect(constraint.ToString(), EqualTo("<orderedby SomePropertyName>"));
        }
Beispiel #3
0
        public void CollectionOrderedBy_Comparer()
        {
            var constraint = Ordered.By("SomePropertyName").Using(ObjectComparer.Default);

            Expect(constraint, TypeOf <CollectionOrderedConstraint>());
            Expect(constraint.ToString(), EqualTo("<orderedby SomePropertyName NUnit.TestUtilities.Comparers.ObjectComparer>"));
        }
        public XmlNode UpdateSettings(XmlDocument document)
        {
            XmlElement xmlSettings = document.CreateElement("Settings");

            XmlElement xmlOrdered = document.CreateElement("Ordered");

            xmlOrdered.InnerText = Ordered.ToString();
            xmlSettings.AppendChild(xmlOrdered);

            XmlElement xmlAutosplitEndRuns = document.CreateElement("AutosplitEndRuns");

            xmlAutosplitEndRuns.InnerText = AutosplitEndRuns.ToString();
            xmlSettings.AppendChild(xmlAutosplitEndRuns);

            XmlElement xmlSplits = document.CreateElement("Splits");

            xmlSettings.AppendChild(xmlSplits);

            foreach (SplitName split in Splits)
            {
                XmlElement xmlSplit = document.CreateElement("Split");
                xmlSplit.InnerText = split.ToString();

                xmlSplits.AppendChild(xmlSplit);
            }

            return(xmlSettings);
        }
Beispiel #5
0
        private void ExecuteAddToCart(object sender)
        {
            Button  button  = sender as Button;
            Product product = (Product)button.DataContext;

            if (MainVM.ProductRepository.GetById(product.Id) != null)
            {
                Ordered ordered = new Ordered()
                {
                    Product = product, Amount = 1
                };
                Order order = MainVM.GetCreatedOrder();
                if (order == null)
                {
                    order = new Order()
                    {
                        Customer = MainVM.Customer, State = State.Created
                    };
                }
                order.Ordered.Add(ordered);
                button.Content   = "В корзине";
                button.IsEnabled = false;
            }
            else
            {
                MessageBox.Show("Товар не найден, пожалуйста, обновите страницу");
            }
        }
Beispiel #6
0
        private async void Notify(UserDto user, int orderId)
        {
            var puchases = await GetPurchaseHistory(user.Id);

            var args = new OrderEventArgs(user, puchases.FirstOrDefault(x => x.Order.Id == orderId));

            Ordered?.Invoke(this, args);
        }
 public void DoesntBailWhenFedNulls ()
 {
     Ordered one = new Ordered (1);
     object [] list = new object [] {null, one, null};
     ArrayUtils.Sort(list, new OrderComparator ());
     Assert.AreEqual (one, list [0], "order comparator instance should be first");
     Assert.AreEqual (null, list [1]);
     Assert.AreEqual (null, list [2]);
 }
Beispiel #8
0
        private void DeleteProductExecute(object sender)
        {
            Button  button  = sender as Button;
            Ordered ordered = button.DataContext as Ordered;

            View.Order.ItemsSource = View.Order.ItemsSource.Cast <Ordered>().Where(ord => ord != ordered);
            Customer.Order.First(order => order.State == State.Created).Ordered.Remove(ordered);
            UpdateTotal();
        }
        public void DoesntBailWhenFedNulls()
        {
            Ordered one = new Ordered(1);

            object [] list = new object [] { null, one, null };
            ArrayUtils.Sort(list, new OrderComparator());
            Assert.AreEqual(one, list [0], "order comparator instance should be first");
            Assert.AreEqual(null, list [1]);
            Assert.AreEqual(null, list [2]);
        }
Beispiel #10
0
 public OrderedDTO CreateOrdered(OrderedDTO order)
 {
     using (var e = new EntityTC())
     {
         Ordered o = _mapper.Map <Ordered>(order);
         e.Ordered.Add(o);
         e.SaveChanges();
         return(_mapper.Map <OrderedDTO>(o));
     }
 }
Beispiel #11
0
        private Task <Listing <Source> > SourcesList()
        {
            Client c = new Client(userName, apiKey);
            Ordered <Source.Filterable, Source.Orderable, Source> result
                = (from s in c.ListSources()
                   orderby s.Created descending
                   select s);

            return(result.InternalTask);
        }
Beispiel #12
0
            public void SwapIndex(int indexA, int indexB)
            {
                Ordered <T> tmp = GetByIndex(indexA);

                indexed[indexA] = GetByIndex(indexB);
                indexed[indexB] = tmp;

                indexed[indexA].Index = indexA;
                indexed[indexB].Index = indexB;
            }
Beispiel #13
0
        public IHttpActionResult GetOrdered(DateTime id)
        {
            Ordered ordered = db.Ordered.Find(id);

            if (ordered == null)
            {
                return(NotFound());
            }

            return(Ok(ordered));
        }
        public virtual TModel Select(Expression <Func <TModel, bool> > predicate, Ordered <TModel, TKey> orderBy = null)
        {
            var strWhere = predicate.ToWhere(null);
            var sqlQuery = "select top 1 * from " + TableName + " where " + strWhere + "";

            if (orderBy != null)
            {
                sqlQuery += " " + orderBy.OrderBySql + "";
            }
            return(Select(sqlQuery));
        }
 public void OrdersCorrectly ()
 {
     Ordered one = new Ordered (1);
     Ordered fifty = new Ordered (50);
     string max = "Max"; // should be stuck at the end 'cos it doesnt implement IOrdered
     object [] list = new object [] {max, one, fifty};
     Array.Sort (list, new OrderComparator ());
     Assert.AreEqual (one, list [0]);
     Assert.AreEqual (fifty, list [1]);
     Assert.AreEqual (max, list [2]);
 }
Beispiel #16
0
        public int Add(Ordered ordered)
        {
            using (MySqlConnection con = new MySqlConnection(conString))
            {
                var sql = @"insert into Ordered(UserId, WasherId, Created, TotalPrice, Status, ScheduledDateTime) 
                                            values(@UserId, @WasherId, @Created, @TotalPrice, @Status, @ScheduledDateTime);
                                            Select @@Identity;";

                return(con.Query <int>(sql, ordered).Single());
            }
        }
        public void OrdersCorrectly()
        {
            Ordered one   = new Ordered(1);
            Ordered fifty = new Ordered(50);
            string  max   = "Max"; // should be stuck at the end 'cos it doesnt implement IOrdered

            object [] list = new object [] { max, one, fifty };
            Array.Sort(list, new OrderComparator());
            Assert.AreEqual(one, list [0]);
            Assert.AreEqual(fifty, list [1]);
            Assert.AreEqual(max, list [2]);
        }
        /// <summary>
        /// Order of creating bean is important.
        /// </summary>
        /// <param name="phase"></param>
        public void ExecutePhase <TApplicationContextPhase>() where TApplicationContextPhase : IApplicationContextPhase
        {
            var defContainer = ApplicationSP.GetService <IBeanDefinitionContainer>();
            var beanDefs     = defContainer.GetAllBeanDefinitions(typeof(TApplicationContextPhase));
            var beans        = beanDefs.Select(def => ApplicationSP.GetRequiredService(def.Type, def.Name))
                               .Cast <IApplicationContextPhase>()
                               .ToArray();

            beans.OrderBy(bean => Ordered.GetOrder(bean.GetType()))
            .ToList()
            .ForEach(bean => bean.Process());
        }
Beispiel #19
0
        public void Handle(Ordered message)
        {
            this.Data.FacilityId = message.FacilityId;
            this.Data.OrderId    = message.OrderId;
            string facilityId = this.Data.FacilityId.ToString("N");

            this.Data.Name = string.Format("VHPT-{0}", facilityId.Substring(0, 6)).ToUpper();

            Console.WriteLine("Installing facility {0} with name {1} for order {2}.", this.Data.FacilityId, this.Data.Name, this.Data.OrderId);

            // This is only for simulation
            this.RequestTimeout <ReadyToInstall>(TimeSpan.FromSeconds(5));
        }
Beispiel #20
0
        public async Task <IActionResult> Create([Bind("Ordered_id,ProductVariant_Id,Order_Id,Amount")] Ordered ordered)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ordered);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Order_Id"]          = new SelectList(_context.Orders, "Order_id", "UserId", ordered.Order_Id);
            ViewData["ProductVariant_Id"] = new SelectList(_context.ProductVariants, "ProductVariant_Id", "ProductVariant_Id", ordered.ProductVariant_Id);
            return(View(ordered));
        }
Beispiel #21
0
        private void AddAmountExecute(object sender)
        {
            Button  button  = sender as Button;
            Ordered ordered = button.DataContext as Ordered;

            ordered.Amount++;

            if (ordered.Amount == ordered.Product.Amount)
            {
                button.IsEnabled = false;
            }
            ((button.Parent as DockPanel).Children[0] as Button).IsEnabled = true;
            UpdateTotal();
        }
Beispiel #22
0
        bool Validate()
        {
            var valid = _date.SelectedDate != null && _time.Value != null &&
                        mazeCombo.SelectedItem != null && Ordered.All(o => o != null) &&
                        _subject.Text != "" && _weight.Value != null;

            if (!valid)
            {
                MessageBox.Show("Debe llenar todos los datos.",
                                "Datos incompletos", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            return(valid);
        }
Beispiel #23
0
        private void ReduceAmountExecute(object sender)
        {
            Button  button  = sender as Button;
            Ordered ordered = button.DataContext as Ordered;

            ordered.Amount--;

            if (ordered.Amount <= 1)
            {
                button.IsEnabled = false;
            }
            ((button.Parent as DockPanel).Children[1] as Button).IsEnabled = true;
            UpdateTotal();
        }
        public virtual List <TModel> SelectTop(int ItemCount, Ordered <TModel, TKey> orderBy = null)
        {
            string sqlQuery = "select top " + ItemCount + " * from " + TableName + "";

            if (orderBy != null)
            {
                sqlQuery += " " + orderBy.OrderBySql + "";
            }
            DbCommand cmd     = db.GetSqlStringCommand(sqlQuery);
            DataTable dt      = db.ExecuteDataSet(cmd).Tables[0];
            var       Objects = dt.ToEntities <TModel>();

            return(Objects);
        }
Beispiel #25
0
        public IHttpActionResult DeleteOrdered(DateTime id)
        {
            Ordered ordered = db.Ordered.Find(id);

            if (ordered == null)
            {
                return(NotFound());
            }

            db.Ordered.Remove(ordered);
            db.SaveChanges();

            return(Ok(ordered));
        }
Beispiel #26
0
 public decimal TotalPriceOfItem(int id = 0)
 {
     if (id > 0 && Ordered.FirstOrDefault(x => x.Id == id) != null)
     {
         return(Ordered.FirstOrDefault(x => x.Id == id).Price *ItemCount[id]);
     }
     else
     {
         decimal returnValue = 0;
         foreach (var item in Ordered)
         {
             returnValue += item.Price * ItemCount[item.Id];
         }
         return(returnValue);
     }
 }
Beispiel #27
0
        public List <Ordered> SelectAllOrdered()
        {
            List <Ordered> ordereds = new List <Ordered>();

            DBConnection  conn   = new DBConnection();
            SqlDataReader reader = conn.ExecuteSelect("Get_ALL_ORDERLIST");

            while (reader.Read())
            {
                Ordered order = new Ordered();
                order.Order_Code    = reader[0].ToString();
                order.Business_Code = reader[1].ToString();
                order.Business_name = reader[2].ToString();

                ordereds.Add(order);
            }
            conn.Close();
            return(ordereds);
        }
Beispiel #28
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TransactionDateOccured?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Status?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Shipped.GetHashCode());
            hashCode = hashCode * -1521134295 + (Invoiced.GetHashCode());
            hashCode = hashCode * -1521134295 + (ShippedDateOccured?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (InvoicedDateOccured?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Cancelled.GetHashCode());
            hashCode = hashCode * -1521134295 + (InTransit.GetHashCode());
            hashCode = hashCode * -1521134295 + (Picked.GetHashCode());
            hashCode = hashCode * -1521134295 + (PaymentStatus.GetHashCode());
            hashCode = hashCode * -1521134295 + (InitialOrderDate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (FinalOrderDate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Delivered.GetHashCode());
            hashCode = hashCode * -1521134295 + (Ordered.GetHashCode());
            return(hashCode);
        }
Beispiel #29
0
        // add async attribute in the event handler
        private async void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            label1.Text     = "Loading...";

            Client c = new Client(userName, apiKey);
            Ordered <Source.Filterable, Source.Orderable, Source> result
                = (from s in c.ListSources()
                   orderby s.Created descending
                   select s);

            Listing <Source> sources = await result; //use await keyword
            int countSources         = 0;

            foreach (Source src in sources)
            {
                countSources++;
            }

            label1.Text     = countSources + " sources found";
            button1.Enabled = true;
        }
Beispiel #30
0
        public ActionResult <OrderResponse> RegisterOrder([FromBody] OrderRequest orderRequest)
        {
            if (!ModelState.IsValid)
            {
                throw new BadRequestException("0003", "badRequestException", "Verify list of field with errors", ModelState);
            }

            List <OrderedItem> items = orderRequest.Items.ConvertAll(itemRequest =>
                                                                     new OrderedItem(itemRequest.Uuid, itemRequest.Amount, itemRequest.UnitValue));
            Ordered orderToRegister = new Ordered(orderRequest.RestaurantUuid, items);

            Order order = _registerOrder.Execute(orderToRegister);

            var restaurantResponse = new RestaurantResponse(order.Restaurant.Uuid, order.Restaurant.Name);
            List <OrderItemResponse> orderItemResponses = order.Items.Select(orderItem =>
                                                                             new OrderItemResponse(orderItem.Uuid, orderItem.Name, orderItem.Amount, orderItem.UnitValue))
                                                          .ToList();
            OrderResponse orderResponse = new OrderResponse(order.Uuid,
                                                            restaurantResponse, orderItemResponses, order.Total);

            return(Ok(new DataResponse <OrderResponse>(orderResponse)));
        }
        private string ToSql(Dictionary <string, string> condition, Ordered <TModel, TKey> orderBy)
        {
            var sql = string.Empty;

            if (condition != null || condition.Count > 0)
            {
                var bWhere = false;
                foreach (var kv in condition)
                {
                    if (!bWhere)
                    {
                        sql   += " where";
                        bWhere = true;
                    }
                    sql += " " + kv.Key + "" + kv.Value + "";
                }
            }
            if (orderBy != null)
            {
                sql += " " + orderBy.OrderBySql + "";
            }
            return(sql);
        }
Beispiel #32
0
 /// <summary>
 /// Retrieves an identified <see cref="IOrdered"/> instance
 /// </summary>
 /// <typeparam name="X">The type over which an order is constructed</typeparam>
 /// <returns></returns>
 public static IOrderOperators <X> orderops <X>()
 => Ordered.orderops <X>().Require();