public async Task <ActionResult <Quantities> > PostQuantities(Quantities quantities)
        {
            _context.quantities.Add(quantities);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetQuantities", new { id = quantities.QuantityId }, quantities));
        }
        //עדכון כמות המלאי בעת שהלקוח מוסיפה אחת מהאופציות שבמלאי לכמויות שלו
        // GET: ConnectTables/Details/quantities
        public async Task <IActionResult> Details(Quantities quantities)
        {
            if (quantities.ProductesId == 0)
            {
                return(NotFound());
            }

            var connectTable = await _context.ConnectTable
                               .Include(c => c.Color)
                               .Include(c => c.Productes)
                               .Include(c => c.Size)
                               .SingleOrDefaultAsync(m => m.ProductesId == quantities.ProductesId && m.ColorId == quantities.ColorId && m.SizeId == quantities.SizeId);

            if (connectTable.AmountInStock < quantities.AmountOfOrders)
            {
                quantities.AmountOfOrders = 0;
                _context.Update(quantities);
                await _context.SaveChangesAsync();
            }
            else
            {
                connectTable.AmountInStock = connectTable.AmountInStock - quantities.AmountOfOrders;
                _context.Update(connectTable);
                await _context.SaveChangesAsync();
            }

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

            return(RedirectToAction("Index", "Quantities"));
        }
Beispiel #3
0
        private bool?DisposeThreeArgs()
        {
            if (!IsThreeArgs)
            {
                return(null);
            }

            var i          = -1;
            var quantities = Quantities.ToArray();

            var xQty = quantities.ElementAt(++i);
            var yQty = quantities.ElementAt(++i);
            var zQty = quantities.ElementAt(++i);

            var expectedValue = ThreeArgExpected(xQty.ToBase().Value,
                                                 yQty.ToBase().Value, zQty.ToBase().Value);

            var expectedQty = ExpectedQty(expectedValue);

            var actualQty = ThreeArgActual(Calculator, xQty, yQty, zQty);

            Assert.That(Comparer.Compare(expectedQty, actualQty), Is.EqualTo(0),
                        "Expected {{{0}}} but was {{{1}}}: x = {{{2}}} y = {{{3}}} z = {{{4}}}.",
                        expectedQty, actualQty, xQty, yQty, zQty);

            Console.WriteLine("Evaluating: {{{0}}}", ThreeArgActual);

            return(true);
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,DishesID,Q_time,Quantity")] Quantities quantities)
        {
            if (id != quantities.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(quantities);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuantitiesExists(quantities.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DishesID"] = new SelectList(_context.Dishes, "ID", "ID", quantities.DishesID);
            return(View(quantities));
        }
        public async Task <IActionResult> PutQuantities(int id, Quantities quantities)
        {
            if (id != quantities.QuantityId)
            {
                return(BadRequest());
            }

            _context.Entry(quantities).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuantitiesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Add([Bind("ProductesId,SizeId,ColorId,MartId,AmountOfOrders")] Quantities quantities)
        {
            if (quantities.MartId != 0)
            {
                _context.Add(quantities);
                await _context.SaveChangesAsync();

                if (!ConnectTableExist(quantities.ProductesId, quantities.SizeId, quantities.ColorId))
                {
                    //כאשר אופציה זו לא נמצאת במלאי(בטבלה המקשרת
                    quantities.AmountOfOrders = 0;
                    _context.Update(quantities);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }

                if (ConnectTableExist(quantities.ProductesId, quantities.SizeId, quantities.ColorId))
                {
                    return(RedirectToAction("Details", "ConnectTables", quantities));
                }
            }

            return(RedirectToAction("LogIn", "Customers"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProductesId,SizeId,ColorId,MartId,AmountOfOrders")] Quantities quantities)
        {
            if (id != quantities.ProductesId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(quantities);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuantitiesExists(quantities.ProductesId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["ColorId"]     = new SelectList(_context.Colors, "Id", "Id", quantities.ColorId);
            ViewData["MartId"]      = new SelectList(_context.Mart, "Id", "Id", quantities.MartId);
            ViewData["ProductesId"] = new SelectList(_context.Productes, "Id", "Id", quantities.ProductesId);
            ViewData["SizeId"]      = new SelectList(_context.Sizes, "Id", "Id", quantities.SizeId);
            return(View(quantities));
        }
Beispiel #8
0
        bool IEquatable <MetricSystem> .Equals(MetricSystem other)
        {
            if (Utils.VerifyStackOverflow())
            {
                return(Name == other.Name);
            }
            else
            {
                var this_OrderedQuantities  = Quantities.OrderBy(q => q.Name);
                var this_OrderedUnits       = Units.OrderBy(u => u.Name);
                var this_OrderedPrefixes    = Prefixes.OrderBy(p => p.Name);
                var other_OrderedQuantities = Quantities.OrderBy(q => q.Name);
                var other_OrderedUnits      = Units.OrderBy(u => u.Name);
                var other_OrderedPrefixes   = Prefixes.OrderBy(p => p.Name);

                Func <bool> quantitiesMatch = () => this_OrderedQuantities.SequenceEqual(other_OrderedQuantities,
                                                                                         new IEquatableEqualityComparer <Quantity>());
                Func <bool> unitsMatch = () => this_OrderedUnits.SequenceEqual(other_OrderedUnits,
                                                                               new IEquatableEqualityComparer <Unit>());
                Func <bool> metricPrefixesMatch = () => other_OrderedPrefixes.SequenceEqual(other_OrderedPrefixes,
                                                                                            new IEquatableEqualityComparer <MetricPrefix>());

                return(Name == other?.Name && quantitiesMatch() && unitsMatch() &&
                       metricPrefixesMatch());
            }
        }
Beispiel #9
0
            /// <summary>
            /// Add a quantity
            /// </summary>
            public void AddQuantity(TrajectoryQuantity q)
            {
                var lastIdx          = Quantities.Count;
                var nOccurancesDelta = q.IsTransition ? 0 : -1;

                TotalTrajectorySize += (Program.Cfg.NSteps + nOccurancesDelta) * q.Length;
                SingleStepSize      += q.Length;

                q.Index = lastIdx;
                if (lastIdx > 0)
                {
                    q.Offset = Quantities.Last().Offset + Quantities.Last().Length;
                }
                else
                {
                    q.Offset = 1;
                }

                if (lastIdx > 0 && Quantities.Last().IsTransition)
                {
                    // Transitions must be added to the end
                    Debug.Assert(q.IsTransition);
                }
                else if (q.IsTransition)
                {
                    // The first transition
                    StateQuantityCount = lastIdx;
                    StateQuantitySize  = q.Offset - 1;
                }
                Quantities.Add(q);
            }
Beispiel #10
0
        public void SyncRead(object sender, EventArgs e)
        {
            tTimer.Stop();
            string LabelName = string.Empty;

            try
            {
                object ItemValues; object Quantities; object TimeStamps;//同步读取临时变量 值 质量 时间戳

                for (int i = 0; i < paramClass.ParamList.Count; i++)
                {
                    opcItem[i].Read(1, out ItemValues, out Quantities, out TimeStamps);
                    if (Quantities.ToString() == "192")
                    {
                        LabelName = paramClass.ParamList[i].LabelName;

                        Type type = paramClass.GetType();                                          //获取类型
                        System.Reflection.PropertyInfo propertyInfo = type.GetProperty(LabelName); //获取指定名称的属性
                        //int value_Old = (int)propertyInfo.GetValue(paramClass, null); //获取属性值
                        if (propertyInfo != null)
                        {
                            propertyInfo.SetValue(paramClass, ItemValues.ToString(), null);                       //给对应属性赋值
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                tTimer.Start();
            }
            tTimer.Start();
        }
Beispiel #11
0
        public void SyncRead(object sender, EventArgs e)
        {
            tTimer.Stop();

            try
            {
                object ItemValues; object Quantities; object TimeStamps;//同步读取临时变量 值 质量 时间戳

                for (int i = 0; i < ModelList.Count; i++)
                {
                    opcItem[i].Read(1, out ItemValues, out Quantities, out TimeStamps);

                    if (Quantities.ToString() == "192")
                    {
                        Address            = ModelList[i].KepAddress;
                        myDcValue[Address] = ItemValues.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                tTimer.Start();
            }
            tTimer.Start();
        }
Beispiel #12
0
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()

        => Media.GetHashCode() * 13 ^
        Channel.GetHashCode() * 11 ^
        Indicator.GetHashCode() * 7 ^
        Mode.GetHashCode() * 5 ^
        Quantities.GetHashCode() * 3 ^
        Storage.GetHashCode();
Beispiel #13
0
        public int GetTotalQuantity(OperationGroups operation)
        {
            if (!Quantities.ContainsKey(operation))
            {
                return(0);
            }

            return(Quantities[operation].Values.Sum());
        }
Beispiel #14
0
        public double GetSpeedQuantityPerHour(OperationGroups operation)
        {
            if (!Quantities.ContainsKey(operation))
            {
                return(0.0);
            }

            return(Quantities[operation].Values.Sum() / OperationTimes[operation].TotalHours);
        }
Beispiel #15
0
        public async Task <IActionResult> Create([Bind("ID,DishesID,Q_time,Quantity")] Quantities quantities)
        {
            if (ModelState.IsValid)
            {
                _context.Add(quantities);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DishesID"] = new SelectList(_context.Dishes, "ID", "ID", quantities.DishesID);
            return(View(quantities));
        }
Beispiel #16
0
        /// <summary>
        /// Compares two OBISs for equality.
        /// </summary>
        /// <param name="OBIS">A OBIS identification to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(OBIS OBIS)
        {
            if ((Object)OBIS == null)
            {
                return(false);
            }

            return(Media.Equals(OBIS.Media) &&
                   Channel.Equals(OBIS.Channel) &&
                   Indicator.Equals(OBIS.Indicator) &&
                   Mode.Equals(OBIS.Mode) &&
                   Quantities.Equals(OBIS.Quantities) &&
                   Storage.Equals(OBIS.Storage));
        }
        public async Task <IActionResult> Create([Bind("ProductesId,SizeId,ColorId,MartId,AmountOfOrders")] Quantities quantities)
        {
            if (ModelState.IsValid)
            {
                _context.Add(quantities);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["ColorId"]     = new SelectList(_context.Colors, "Id", "Id", quantities.ColorId);
            ViewData["MartId"]      = new SelectList(_context.Mart, "Id", "Id", quantities.MartId);
            ViewData["ProductesId"] = new SelectList(_context.Productes, "Id", "Id", quantities.ProductesId);
            ViewData["SizeId"]      = new SelectList(_context.Sizes, "Id", "Id", quantities.SizeId);
            return(View(quantities));
        }
        public Dictionary <AugmentorType, int> GetAugmentorQuantities()
        {
            Dictionary <AugmentorType, int> Result = new Dictionary <AugmentorType, int>();

            foreach (AugmentorType Type in Enum.GetValues(typeof(AugmentorType)).Cast <AugmentorType>())
            {
                int Qty = 0;
                if (Quantities != null)
                {
                    Quantities.TryGetValue(Type, out Qty);
                }
                Result.Add(Type, Qty);
            }
            return(Result);
        }
Beispiel #19
0
        public Quantities Convert(Quantities from, Units toUnit)
        {
            var conversionRatio = _rep.ConversionRatios.FirstOrDefault(x => x.FromUnitId == from.Id && x.ToUnitId == toUnit.Id);

            if (conversionRatio.Equals(null))
            {
                return(null);
            }

            return(new Quantities
            {
                Id = from.Id,
                Amount = conversionRatio.Ratio * from.Amount,
                Unit = toUnit
            });
        }
Beispiel #20
0
        /// <summary>
        /// Calculates the conversion multiplier needed to convert between two Units
        /// </summary>
        /// <param name="currentUnit">The starting unit</param>
        /// <param name="newUnit">The target unit</param>
        /// <returns>Multyplier as a double</returns>
        public static double GetUnitConversion(Units currentUnit, Units newUnit)
        {
            Quantities currentQuantity = currentUnit.GetQuantity();
            Quantities newQuantity     = newUnit.GetQuantity();

            double conversion;

            if (currentQuantity == newQuantity)
            {
                // The units can be converted between

                UnitSystems currentSystem = currentUnit.GetSystem();
                UnitSystems newSystem     = newUnit.GetSystem();

                if (currentSystem == newSystem)
                {
                    // Same system - convert from current unit to base to new unit
                    // new * 1/current
                    conversion = newUnit.GetBaseMultyplier() / currentUnit.GetBaseMultyplier();
                }
                else
                {
                    // Systems are different - convert to system base -> convert to new system -> convert to new unit

                    Units currentSystemBaseUnit = currentQuantity.GetSystemBaseUnit(currentSystem);
                    Units newSystemBaseUnit     = newQuantity.GetSystemBaseUnit(newSystem);

                    conversion = GetUnitConversion(currentUnit, currentQuantity.GetSystemBaseUnit(currentSystem));

                    Dictionary <Units, double> conversions = currentQuantity.GetSystemConversions();

                    conversion *= conversions[newQuantity.GetSystemBaseUnit(newSystem)] / conversions[currentQuantity.GetSystemBaseUnit(currentSystem)];

                    conversion *= GetUnitConversion(newQuantity.GetSystemBaseUnit(newSystem), newUnit);
                }

                return(conversion);
            }
            else
            {
                // The units refer to different quantities so can't be converted
                throw new ArgumentException("Unit conversion failed - the units provided are for different quantities and therfore can't be converted.");
            }
        }
Beispiel #21
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="proxy">XML proxy.</param>
        /// <exception cref="XNeut.InvalidMessageException">Thrown if an error is encountered.</exception>
        internal MaterialRequirement(XsdNs.MaterialRequirementType proxy)
            : this() // Call the default constructor
        {
            if (proxy.MaterialDefinitionID != null)
            {
                foreach (var idProxy in proxy.MaterialDefinitionID)
                {
                    MaterialDefinitionIdentifiers.Add(new IdentifierType(idProxy)); // throws InvalidMessageException
                }
            }

            if (proxy.MaterialLotID != null)
            {
                foreach (var idProxy in proxy.MaterialLotID)
                {
                    MaterialLotIdentifiers.Add(new IdentifierType(idProxy)); // throws InvalidMessageException
                }
            }

            if (proxy.MaterialUse != null)
            {
                MaterialUse = new MaterialUse(proxy.MaterialUse); // throws InvalidMessageException
            }

            if (proxy.Quantity != null)
            {
                foreach (var qItem in proxy.Quantity)
                {
                    Quantities.Add(new QuantityValue(qItem)); // throws InvalidMessageException
                }
            }

            if (proxy.AssemblyRequirement != null)
            {
                foreach (var arItem in proxy.AssemblyRequirement)
                {
                    AssemblyRequirements.Add(new MaterialRequirement(arItem)); // throws InvalidMessageException
                }
            }
        }
Beispiel #22
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="OBIS">An object to compare with.</param>
        public Int32 CompareTo(OBIS OBIS)
        {
            if ((Object)OBIS == null)
            {
                throw new ArgumentNullException(nameof(OBIS), "The given OBIS identification must not be null!");
            }

            var c = Media.CompareTo(OBIS.Media);

            if (c != 0)
            {
                return(c);
            }

            c = Channel.CompareTo(OBIS.Channel);
            if (c != 0)
            {
                return(c);
            }

            c = Indicator.CompareTo(OBIS.Indicator);
            if (c != 0)
            {
                return(c);
            }

            c = Mode.CompareTo(OBIS.Mode);
            if (c != 0)
            {
                return(c);
            }

            c = Quantities.CompareTo(OBIS.Quantities);
            if (c != 0)
            {
                return(c);
            }

            return(Storage.CompareTo(OBIS.Storage));
        }
Beispiel #23
0
 public void MergeFrom(LodgingSnapshotResponseRecord other)
 {
     if (other == null)
     {
         return;
     }
     if (other.roomType_ != null)
     {
         if (roomType_ == null)
         {
             roomType_ = new global::HOLMS.Types.Supply.RoomTypes.RoomTypeIndicator();
         }
         RoomType.MergeFrom(other.RoomType);
     }
     if (other.date_ != null)
     {
         if (date_ == null)
         {
             date_ = new global::HOLMS.Types.Primitive.PbLocalDate();
         }
         Date.MergeFrom(other.Date);
     }
     if (other.offeredPrice_ != null)
     {
         if (offeredPrice_ == null)
         {
             offeredPrice_ = new global::HOLMS.Types.Primitive.MonetaryAmount();
         }
         OfferedPrice.MergeFrom(other.OfferedPrice);
     }
     if (other.quantities_ != null)
     {
         if (quantities_ == null)
         {
             quantities_ = new global::HOLMS.Types.Supply.Snapshot.LodgingSnapshotQuantity();
         }
         Quantities.MergeFrom(other.Quantities);
     }
     requiredReservationTags_.Add(other.requiredReservationTags_);
 }
Beispiel #24
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (roomType_ != null)
            {
                hash ^= RoomType.GetHashCode();
            }
            if (date_ != null)
            {
                hash ^= Date.GetHashCode();
            }
            if (offeredPrice_ != null)
            {
                hash ^= OfferedPrice.GetHashCode();
            }
            if (quantities_ != null)
            {
                hash ^= Quantities.GetHashCode();
            }
            hash ^= requiredReservationTags_.GetHashCode();
            return(hash);
        }
Beispiel #25
0
        public void Initialize()
        {
            var optionsBuilder = new DbContextOptionsBuilder <NorthwindContext>();

            optionsBuilder.UseInMemoryDatabase("DefaultConnection");
            var context = new NorthwindContext(optionsBuilder.Options);

            var USD = new Units
            {
                Name = "USD"
            };
            var SEK = new Units
            {
                Name = "SEK"
            };

            context.ConversionRatios.Add(
                new ConversionRatio
            {
                FromUnit = USD,
                ToUnit   = SEK,
                Ratio    = 8.40M
            });

            context.SaveChanges();

            _quantity = new Quantities
            {
                Amount = 100,
                Unit   = USD
            };

            _sek = SEK;

            _unitConverter = new UnitConverter(context);
        }
 public bool HasAugmentors()
 {
     return(Quantities != null && Quantities.Any(x => x.Value > 0));
 }
        /// <param name="RemoveFromInventory">True if the given <paramref name="Qty"/> should be removed from the player's inventory.</param>
        /// <param name="Instance">If <paramref name="RemoveFromInventory"/>=true, this Instance's Stack will be reduced. If not specified, the first instance found in the player's inventory will be reduced.</param>
        internal void OnAugmentorPlaced(AugmentorType Type, int Qty, bool RemoveFromInventory, Augmentor Instance = null)
        {
            int MaxQuantity = MachineAugmentorsMod.UserConfig.GetConfig(Type).MaxAttachmentsPerMachine;
            int CurrentQty  = 0;

            Quantities.TryGetValue(Type, out CurrentQty);
            int ActualQtyPlaced = Math.Max(0, Math.Min(MaxQuantity - CurrentQty, Qty));

            if (ActualQtyPlaced <= 0)
            {
                return;
            }

            if (Quantities.ContainsKey(Type))
            {
                Quantities[Type] += ActualQtyPlaced;
            }
            else
            {
                Quantities.Add(Type, ActualQtyPlaced);
            }

            if (RemoveFromInventory)
            {
                int PendingRemoval = ActualQtyPlaced;
                if (Instance != null && Game1.player.Items.Contains(Instance))
                {
                    int Amt = Math.Min(Instance.Stack, PendingRemoval);
                    if (Amt == Instance.Stack)
                    {
                        Game1.player.Items[Game1.player.Items.IndexOf(Instance)] = null;
                    }
                    else
                    {
                        Instance.Stack -= Amt;
                    }
                }
                else
                {
                    for (int i = 0; i < Game1.player.Items.Count; i++)
                    {
                        Item Item = Game1.player.Items[i];
                        if (Item != null && Item is Augmentor Augmentor && Augmentor.AugmentorType == Type)
                        {
                            int Amt = Math.Min(Augmentor.Stack, PendingRemoval);
                            if (Amt == Augmentor.Stack)
                            {
                                Game1.player.Items[i] = null;
                            }
                            else
                            {
                                Item.Stack -= Amt;
                            }

                            PendingRemoval -= Amt;
                            if (PendingRemoval <= 0)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #28
0
        public static void Initialize(SmartLunchContext context)
        {
            context.Database.EnsureCreated();
            if (context.Forms.Any())
            {
                return;
            }

            var forms = new Forms[]
            {
                new Forms {
                    ID = 1, Name_form = "11 В"
                },
                new Forms {
                    ID = 2, Name_form = "11 Б"
                },
                new Forms {
                    ID = 3, Name_form = "11 А"
                },
                new Forms {
                    ID = 4, Name_form = "10 А"
                },
                new Forms {
                    ID = 5, Name_form = "10 Б"
                },
                new Forms {
                    ID = 6, Name_form = "10 В"
                },
                new Forms {
                    ID = 8, Name_form = "9 Б"
                },
                new Forms {
                    ID = 9, Name_form = "9 А"
                }
            };

            foreach (Forms f in forms)
            {
                context.Forms.Add(f);
            }
            context.SaveChanges();

            var dishes = new Dishes[]
            {
                new Dishes {
                    ID = 2, Name_dish = "Шашлик", TypesID = 1, description = "150 г"
                },
                new Dishes {
                    ID = 3, Name_dish = "Компот", TypesID = 5, description = "200 мл"
                },
                new Dishes {
                    ID = 4, Name_dish = "Борщ", TypesID = 1, description = "300 г"
                },
                new Dishes {
                    ID = 5, Name_dish = "Котлета", TypesID = 2, description = "100 г"
                },
                new Dishes {
                    ID = 6, Name_dish = "Рис", TypesID = 4, description = "150 г"
                },
                new Dishes {
                    ID = 7, Name_dish = "Макарони", TypesID = 4, description = "200 г"
                },
                new Dishes {
                    ID = 9, Name_dish = "Гречка", TypesID = 4, description = "200 г"
                },
                new Dishes {
                    ID = 10, Name_dish = "Рис", TypesID = 4, description = "300 г"
                },
                new Dishes {
                    ID = 11, Name_dish = "Відбивна", TypesID = 2, description = "200 г"
                },
                new Dishes {
                    ID = 12, Name_dish = "Хек", TypesID = 6, description = "200 г"
                },
                new Dishes {
                    ID = 13, Name_dish = "Булочка з корицею", TypesID = 7, description = "100 г"
                }
            };

            foreach (Dishes d in dishes)
            {
                context.Dishes.Add(d);
            }
            context.SaveChanges();

            var types = new Types[]
            {
                new Types {
                    ID = 1, Name_type = "Суп"
                },
                new Types {
                    ID = 2, Name_type = "М'ясо"
                },
                new Types {
                    ID = 4, Name_type = "Гарнір"
                },
                new Types {
                    ID = 5, Name_type = "Напій"
                },
                new Types {
                    ID = 6, Name_type = "Риба"
                },
                new Types {
                    ID = 7, Name_type = "Десерт"
                }
            };

            foreach (Types t in types)
            {
                context.Types.Add(t);
            }
            context.SaveChanges();

            var prices = new Prices[]
            {
                new Prices {
                    ID = 2, Price = 12, DishesID = 2, P_time = DateTime.Parse("2019-03-20 22:15:21.480")
                },
                new Prices {
                    ID = 3, Price = 8, DishesID = 3, P_time = DateTime.Parse("2019-03-20 22:57:56.510")
                },
                new Prices {
                    ID = 2, Price = 10, DishesID = 5, P_time = DateTime.Parse("2019-03-21 01:37:29.110")
                },
                new Prices {
                    ID = 2, Price = 14, DishesID = 6, P_time = DateTime.Parse("2019-03-21 01:37:35.073")
                },
                new Prices {
                    ID = 2, Price = 19, DishesID = 7, P_time = DateTime.Parse("2019-03-21 01:37:38.837")
                },
                new Prices {
                    ID = 3, Price = 19, DishesID = 8, P_time = DateTime.Parse("2019-03-21 01:37:44.237")
                },
                new Prices {
                    ID = 3, Price = 15, DishesID = 9, P_time = DateTime.Parse("2019-03-21 01:37:48.780")
                },
                new Prices {
                    ID = 3, Price = 13, DishesID = 10, P_time = DateTime.Parse("2019-03-21 01:37:52.110")
                },
                new Prices {
                    ID = 4, Price = 12, DishesID = 11, P_time = DateTime.Parse("2019-03-21 03:25:34.267")
                },
                new Prices {
                    ID = 5, Price = 7, DishesID = 12, P_time = DateTime.Parse("2019-03-21 03:26:53.157")
                },
                new Prices {
                    ID = 6, Price = 5, DishesID = 13, P_time = DateTime.Parse("2019-03-21 03:31:26.417")
                },
                new Prices {
                    ID = 6, Price = 6, DishesID = 14, P_time = DateTime.Parse("2019-03-21 03:55:03.587")
                },
                new Prices {
                    ID = 5, Price = 8, DishesID = 15, P_time = DateTime.Parse("2019-03-21 03:55:29.040")
                },
                new Prices {
                    ID = 2, Price = 18, DishesID = 16, P_time = DateTime.Parse("2019-03-21 03:58:51.267")
                },
                new Prices {
                    ID = 4, Price = 13, DishesID = 17, P_time = DateTime.Parse("2019-03-21 03:59:10.180")
                },
                new Prices {
                    ID = 7, Price = 9, DishesID = 18, P_time = DateTime.Parse("2019-03-21 09:34:33.327")
                },
                new Prices {
                    ID = 2, Price = 16, DishesID = 20, P_time = DateTime.Parse("2019-03-21 10:25:58.737")
                },
                new Prices {
                    ID = 2, Price = 17, DishesID = 21, P_time = DateTime.Parse("2019-03-27 18:01:07.797")
                },
                new Prices {
                    ID = 7, Price = 10, DishesID = 22, P_time = DateTime.Parse("2019-03-27 18:08:41.763")
                },
                new Prices {
                    ID = 9, Price = 7, DishesID = 23, P_time = DateTime.Parse("2019-03-27 18:29:51.573")
                },
                new Prices {
                    ID = 6, Price = 3, DishesID = 24, P_time = DateTime.Parse("2019-03-27 19:12:12.187")
                },
                new Prices {
                    ID = 10, Price = 6, DishesID = 25, P_time = DateTime.Parse("2019-03-27 23:08:28.137")
                },
                new Prices {
                    ID = 6, Price = 4, DishesID = 26, P_time = DateTime.Parse("2019-03-27 23:15:09.673")
                },
                new Prices {
                    ID = 11, Price = 10, DishesID = 27, P_time = DateTime.Parse("2019-03-27 23:26:10.133")
                },
                new Prices {
                    ID = 12, Price = 11, DishesID = 28, P_time = DateTime.Parse("2019-03-27 23:27:42.600")
                },
                new Prices {
                    ID = 13, Price = 10, DishesID = 29, P_time = DateTime.Parse("2019-03-28 09:37:34.663")
                },
                new Prices {
                    ID = 5, Price = 10, DishesID = 30, P_time = DateTime.Parse("2019-03-28 09:41:15.740")
                },
                new Prices {
                    ID = 13, Price = 12, DishesID = 31, P_time = DateTime.Parse("2019-03-26 09:44:46.843")
                },
                new Prices {
                    ID = 13, Price = 12, DishesID = 32, P_time = DateTime.Parse("2019-03-26 09:45:04.670")
                }
            };

            foreach (Prices p in prices)
            {
                context.Prices.Add(p);
            }
            context.SaveChanges();

            var quantities = new Quantities[]
            {
                new Quantities {
                    ID = 1, DishesID = 2, Quantity = 0, Q_time = DateTime.Parse("2019-03-20 22:15:21.480")
                },
                new Quantities {
                    ID = 2, DishesID = 3, Quantity = 0, Q_time = DateTime.Parse("2019-03-20 22:57:57.270")
                },
                new Quantities {
                    ID = 3, DishesID = 4, Quantity = 0, Q_time = DateTime.Parse("2019-03-21 03:25:34.690")
                },
                new Quantities {
                    ID = 4, DishesID = 5, Quantity = 0, Q_time = DateTime.Parse("2019-03-21 03:26:53.163")
                },
                new Quantities {
                    ID = 5, DishesID = 6, Quantity = 0, Q_time = DateTime.Parse("2019-03-21 03:31:26.420")
                },
                new Quantities {
                    ID = 6, DishesID = 2, Quantity = 5, Q_time = DateTime.Parse("2019-03-21 04:12:23.940")
                },
                new Quantities {
                    ID = 7, DishesID = 3, Quantity = 10, Q_time = DateTime.Parse("2019-03-21 04:12:49.627")
                },
                new Quantities {
                    ID = 8, DishesID = 2, Quantity = 4, Q_time = DateTime.Parse("2019-03-21 04:14:24.010")
                },
                new Quantities {
                    ID = 9, DishesID = 2, Quantity = 3, Q_time = DateTime.Parse("2019-03-21 04:16:26.963")
                },
                new Quantities {
                    ID = 10, DishesID = 7, Quantity = 0, Q_time = DateTime.Parse("2019-03-21 09:34:33.343")
                },
                new Quantities {
                    ID = 12, DishesID = 4, Quantity = 5, Q_time = DateTime.Parse("2019-03-21 10:26:12.457")
                },
                new Quantities {
                    ID = 13, DishesID = 5, Quantity = 8, Q_time = DateTime.Parse("2019-03-27 18:22:41.643")
                },
                new Quantities {
                    ID = 14, DishesID = 9, Quantity = 0, Q_time = DateTime.Parse("2019-03-27 18:29:51.583")
                },
                new Quantities {
                    ID = 15, DishesID = 10, Quantity = 0, Q_time = DateTime.Parse("2019-03-27 23:08:28.143")
                },
                new Quantities {
                    ID = 16, DishesID = 11, Quantity = 0, Q_time = DateTime.Parse("2019-03-27 23:26:10.140")
                },
                new Quantities {
                    ID = 17, DishesID = 12, Quantity = 0, Q_time = DateTime.Parse("2019-03-27 23:27:42.607")
                },
                new Quantities {
                    ID = 18, DishesID = 12, Quantity = 10, Q_time = DateTime.Parse("2019-03-27 23:28:00.597")
                },
                new Quantities {
                    ID = 19, DishesID = 12, Quantity = 0, Q_time = DateTime.Parse("2019-03-27 23:42:05.640")
                },
                new Quantities {
                    ID = 20, DishesID = 12, Quantity = 10, Q_time = DateTime.Parse("2019-03-27 23:42:08.717")
                },
                new Quantities {
                    ID = 21, DishesID = 13, Quantity = 0, Q_time = DateTime.Parse("2019-03-28 09:37:34.680")
                },
                new Quantities {
                    ID = 22, DishesID = 10, Quantity = 10, Q_time = DateTime.Parse("2019-04-17 18:14:43.363")
                },
                new Quantities {
                    ID = 23, DishesID = 10, Quantity = 0, Q_time = DateTime.Parse("2019-04-17 18:14:57.817")
                }
            };

            foreach (Quantities q in quantities)
            {
                context.Quantities.Add(q);
            }
            context.SaveChanges();
        }
Beispiel #29
0
 /// <summary>
 /// Gets a dictionary of relitive values for the base quantities in a unit system. The SI unit normaly takes a value of 1
 /// </summary>
 /// <param name="currentQuantity"></param>
 /// <returns></returns>
 public static Dictionary <Units, double> GetSystemConversions(this Quantities currentQuantity)
 {
     return(conversions[(int)currentQuantity]);
 }
Beispiel #30
0
        /// <summary>
        /// Gets the base unit for a quantity in a system
        /// </summary>
        /// <param name="quantity">The quantity</param>
        /// /// <param name="system">The unisystemt</param>
        /// <returns>The quantity's base unit in the system</returns>
        public static Units GetSystemBaseUnit(this Quantities quantity, UnitSystems system)
        {
            Units result;

            switch (quantity)
            {
            case Quantities.None:
                switch (system)
                {
                case UnitSystems.None:
                    result = Units.NoUnit;
                    break;

                default:
                    throw new ArgumentException("The quantity dosen't exist in the specified system.");
                }
                break;

            case Quantities.Angle:
                switch (system)
                {
                case UnitSystems.Degrees:
                    result = Units.Degrees;
                    break;

                case UnitSystems.Radians:
                    result = Units.Radians;
                    break;

                default:
                    throw new ArgumentException("The quantity dosen't exist in the specified system.");
                }
                break;

            case Quantities.Distance:
                switch (system)
                {
                case UnitSystems.SI:
                    result = Units.m;
                    break;

                default:
                    throw new ArgumentException("The quantity dosen't exist in the specified system.");
                }
                break;

            case Quantities.Mass:
                switch (system)
                {
                case UnitSystems.SI:
                    result = Units.Kg;
                    break;

                case UnitSystems.Imperial:
                    result = Units.lb;
                    break;

                default:
                    throw new ArgumentException("The quantity dosen't exist in the specified system.");
                }
                break;

            case Quantities.Time:
                switch (system)
                {
                case UnitSystems.Time:
                    result = Units.s;
                    break;

                default:
                    throw new ArgumentException("The quantity dosen't exist in the specified system.");
                }
                break;

            default:
                throw new ArgumentException("The quantity dosen't exist.");
            }

            return(result);
        }