public async Task <IHttpActionResult> PostStorageSize(StorageSize storageSize)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.StorageSizes.Add(storageSize);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (StorageSizeExists(storageSize.StorageSizeId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = storageSize.StorageSizeId }, storageSize));
        }
        public async Task <IHttpActionResult> PutStorageSize(int id, StorageSize storageSize)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != storageSize.StorageSizeId)
            {
                return(BadRequest());
            }

            db.Entry(storageSize).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public override string ToString()
        {
            string result = "Storage: " + ItemList.Count.ToString() + "/" + StorageSize.ToString();

            foreach (Agent ag in ItemList)
            {
                result += "\n   " + ag.Name;
            }

            return(result);
        }
        public async Task <IHttpActionResult> GetStorageSize(int id)
        {
            StorageSize storageSize = await db.StorageSizes.FindAsync(id);

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

            return(Ok(storageSize));
        }
Esempio n. 5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (FolderId.Length != 0)
            {
                hash ^= FolderId.GetHashCode();
            }
            if (createdAt_ != null)
            {
                hash ^= CreatedAt.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            hash ^= Labels.GetHashCode();
            if (Family.Length != 0)
            {
                hash ^= Family.GetHashCode();
            }
            if (StorageSize != 0L)
            {
                hash ^= StorageSize.GetHashCode();
            }
            if (MinDiskSize != 0L)
            {
                hash ^= MinDiskSize.GetHashCode();
            }
            hash ^= productIds_.GetHashCode();
            if (Status != global::Yandex.Cloud.Compute.V1.Image.Types.Status.Unspecified)
            {
                hash ^= Status.GetHashCode();
            }
            if (os_ != null)
            {
                hash ^= Os.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 6
0
        private static BaseEntity SpawnContainer(StorageSize size = StorageSize.Medium, Vector3 position = default(Vector3))
        {
            var ent = GameManager.server.CreateEntity(GetContainerPrefab(size), position);

            ent.UpdateNetworkGroup();
            ent.SendNetworkUpdateImmediate();

            ent.globalBroadcast = true;

            ent.Spawn();

            return(ent);
        }
        public async Task <IHttpActionResult> DeleteStorageSize(int id)
        {
            StorageSize storageSize = await db.StorageSizes.FindAsync(id);

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

            db.StorageSizes.Remove(storageSize);
            await db.SaveChangesAsync();

            return(Ok(storageSize));
        }
        public void GenericUsage()
        {
            var a = new StorageSize(12345);
            var b = new StorageSize(12345);
            var c = new StorageSize(12345);

            var total = new StorageSize(12345 * 3);

            Assert.IsTrue(a.Equals(b));
            Assert.IsTrue(b.Equals(c));

            Assert.IsTrue(total.Equals(a * 3));
            Assert.IsTrue(total.Equals(b * 3));
            Assert.IsTrue(total.Equals(c * 3));

            Assert.IsTrue(a == b);
            Assert.IsTrue(b == c);
            Assert.IsTrue(c == a);

            Assert.IsTrue(a != total);
            Assert.IsTrue(b != total);
            Assert.IsTrue(c != total);

            Assert.AreEqual(a + b, b + c);
            Assert.AreEqual(b + c, c + a);

            Assert.AreEqual(a - b, b - c);
            Assert.AreEqual(b - c, c - a);

            Assert.AreEqual(a + b + c, total);

            Assert.AreEqual(a + b + c, a * 3);
            Assert.AreEqual(a + b + c, b * 3);
            Assert.AreEqual(a + b + c, c * 3);

            Assert.AreEqual(a, total / 3);
            Assert.AreEqual(b, total / 3);
            Assert.AreEqual(c, total / 3);

            Assert.IsTrue(total > a);
            Assert.IsTrue(total > b);
            Assert.IsTrue(total > c);

            Assert.IsTrue(a < b + c);
            Assert.IsTrue(b < a + c);
            Assert.IsTrue(c < a + b);

            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
            Assert.AreEqual(b.GetHashCode(), c.GetHashCode());
        }
Esempio n. 9
0
        public static string GetStorageSize(this StorageSize me)
        {
            switch (me)
            {
            case StorageSize.Small:
                return("512GB");

            case StorageSize.Medium:
                return("1TB");

            case StorageSize.Huge:
            default:
                return("2TB");
            }
        }
Esempio n. 10
0
        public static string GetContainerPrefab(StorageSize size)
        {
            switch (size)
            {
            case StorageSize.Large:
                return("assets/prefabs/deployable/large wood storage/box.wooden.large.prefab");

            case StorageSize.Medium:
                return("assets/prefabs/deployable/woodenbox/woodbox_deployed.prefab");

            case StorageSize.Small:
                return("assets/prefabs/deployable/small stash/small_stash_deployed.prefab");
            }

            return(null);
        }
Esempio n. 11
0
        private static string GetCapacity(long capacity)
        {
            StorageSize suffix   = GetSuffix(capacity);
            double      dividend = ((double)1000 * ((int)suffix));

            if ((int)suffix == 0)
            {
                dividend = 1;
            }

            return(suffix switch
            {
                _ when suffix >= StorageSize.Infinity => "∞",
                _ when suffix >= StorageSize.B => $"{capacity / dividend}",
                _ => throw new ArgumentOutOfRangeException(nameof(suffix), "The specified suffix is out of range")
            });
Esempio n. 12
0
        public static string WriteCapacity(long capacity)
        {
            StorageSize suffix = GetSuffix(capacity);

            return($"**{GetCapacity(capacity)} {((int)suffix >= 5 ? "" : suffix.ToString())}**");
        }
Esempio n. 13
0
 public SSD(string manufacturer, string productsName, string serialNumber, int price, DateTime dateOfPurchase, DateTime dateOfAdd, DateTime warranty, string text, int gb, ConnectorType connectorType, int condition, StorageSize size, int writeSpeed, int readSpeed, Technology technology) : base(manufacturer, productsName, serialNumber, price, dateOfPurchase, dateOfAdd, warranty, text, gb, connectorType, condition, size)
 {
     WriteSpeed = writeSpeed;
     ReadSpeed  = readSpeed;
     Technology = technology;
 }
Esempio n. 14
0
 public HDD(string manufacturer, string productsName, string serialNumber, int price, DateTime dateOfPurchase, DateTime dateOfAdd, DateTime warranty, string text, int gb, ConnectorType connectorType, int condition, StorageSize size, int rpm, int bufferSize) : base(manufacturer, productsName, serialNumber, price, dateOfPurchase, dateOfAdd, warranty, text, gb, connectorType, condition, size)
 {
     Rpm        = rpm;
     BufferSize = bufferSize;
 }