public async void GetHardDrivesFromDatabaseTest()
        {
            var options = new DbContextOptionsBuilder <CheapWareContext>()
                          .UseInMemoryDatabase(databaseName: "GetHardDrivesFromDatabase")
                          .Options;
            var harddrive = new HardDrives {
                Name = "test name", Category = "SSD", Size = "500GB", Speed = "7200RPM", Price = 100.99M
            };
            List <HardDrive> listofharddrives = null;

            using (var context = new CheapWareContext(options))
            {
                context.Add(harddrive);
                context.SaveChanges();
            }

            using (var context = new CheapWareContext(options))
            {
                var service = new ComputerRepo(context);
                listofharddrives = await service.GetHardDrives();
            }


            using (var context = new CheapWareContext(options))
            {
                Assert.Single(listofharddrives);
                Assert.Equal("test name", context.HardDrives.Single().Name);
            }
        }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        bios     = GameObject.Find("BIOS");
        hardware = GameObject.Find("Hardware");

        windowRect = new Rect(0, 0, Customize.cust.RezX, Customize.cust.RezY);
        //pui = GetComponent<ProfileUI>();
        //accset = GetComponent<AccSetup>();
        //lbg = GetComponent<LoginBackground>();
        biosselect = bios.GetComponent <BIOSSelect>();
        boot       = GetComponent <Boot>();
        OScheck    = GetComponent <OSCheck>();
        ram        = hardware.GetComponent <RAM>();
        harddrives = hardware.GetComponent <HardDrives>();
        cpu        = hardware.GetComponent <CPU>();
        Crash      = GameObject.Find("Crash");
        SCM        = Crash.GetComponent <SysCrashMan>();
        cd         = GameControl.control.BootTime;
        cooldown   = 0.256f;
        cooldown1  = 0.256f;
        Screen.SetResolution(Customize.cust.RezX, Customize.cust.RezY, Customize.cust.FullScreen);
        GameControl.control.TimeMulti = 1;

        if (Application.isEditor == true)
        {
            windowRect.width  = Screen.width;
            windowRect.height = Screen.height;
        }
        else
        {
            windowRect.width  = Customize.cust.RezX;
            windowRect.height = Customize.cust.RezY;
        }
    }
Exemple #3
0
        public async Task <ActionResult> Create(HardDrives hd)
        {
            try
            {
                string jsonString = JsonConvert.SerializeObject(hd);

                var request = new HttpRequestMessage(HttpMethod.Post, "api/harddrives");
                {
                    // we set what the Content-Type header will be here
                    request.Content = new StringContent(jsonString, Encoding.UTF8, "application/json");
                };

                var response = await HttpClient.SendAsync(request);

                if (!response.IsSuccessStatusCode)
                {
                    return(View("Error"));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemple #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            HardDrives hardDrives = db.HardDrives.Find(id);

            db.HardDrives.Remove(hardDrives);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "HDId,Name")] HardDrives hardDrives)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hardDrives).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hardDrives));
 }
Exemple #6
0
        public ActionResult Add([Bind(Include = "HDId,Name")] HardDrives hardDrives)
        {
            if (ModelState.IsValid)
            {
                db.HardDrives.Add(hardDrives);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hardDrives));
        }
Exemple #7
0
        // GET: HardDrives/Delete
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HardDrives hardDrives = db.HardDrives.Find(id);

            if (hardDrives == null)
            {
                return(HttpNotFound());
            }
            return(View(hardDrives));
        }
Exemple #8
0
        // GET: Inventorys/Details/5
        public async Task <ActionResult> Details(string name)
        {
            var request = CreateRequestToService(HttpMethod.Get, "api/harddrives/" + name);

            try
            {
                var response = await HttpClient.SendAsync(request);

                if (!response.IsSuccessStatusCode)
                {
                    return(View("Error"));
                }
                string jsonString = await response.Content.ReadAsStringAsync();

                HardDrives hd = JsonConvert.DeserializeObject <HardDrives>(jsonString);

                return(View(hd));
            }
            catch (HttpRequestException)
            {
                return(View("Error"));
            }
        }