public void DeletePcStorage(PcStorageDto pcStorage)
        {
            var pcStorageToDelete = this.context.storages.FirstOrDefault(c => c.model == pcStorage.model);

            this.context.storages.Remove(pcStorageToDelete);

            this.context.SaveChanges();
        }
Exemplo n.º 2
0
 public IActionResult AddPcStorage(PcStorageDto storage)
 {
     if (ModelState.IsValid)
     {
         componentService.CreatePcStorage(storage);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(AddPcStorage()));
 }
 public PcStorage OfPcStorageDto(PcStorageDto storage)
 {
     return(new PcStorage()
     {
         model = storage.model,
         memeorySize = storage.memeorySize,
         price = storage.price,
         readSpeed = storage.readSpeed,
         ssdOrHdd = storage.ssdOrHdd,
         writeSpeed = storage.writeSpeed
     });
 }
Exemplo n.º 4
0
 public IActionResult AddPcStorage(PcStorageDto storage)
 {
     if (ModelState.IsValid)
     {
         if (componentService.HasTheSameIdInBase(storage.model))
         {
             return(NotFound("A storage with the same model already exits"));
         }
         componentService.CreatePcStorage(storage);
         return(RedirectToAction(nameof(AddPcStorage)));
     }
     return(View(AddPcStorage()));
 }
        public PcStorageDto GetPcStorageById(string id)
        {
            PcStorageDto pcStorageDto = new PcStorageDto();
            PcStorage    pcSorage     = this.context.storages.FirstOrDefault(x => x.model == id);


            pcStorageDto.model       = pcSorage.model;
            pcStorageDto.memeorySize = pcSorage.memeorySize;
            pcStorageDto.price       = pcSorage.price;
            pcStorageDto.readSpeed   = pcSorage.readSpeed;
            pcStorageDto.ssdOrHdd    = pcSorage.ssdOrHdd;
            pcStorageDto.writeSpeed  = pcSorage.writeSpeed;

            return(pcStorageDto);
        }
 public void CreatePcStorage(PcStorageDto storage)
 {
     this.context.storages.Add(this.OfPcStorageDto(storage));
     this.context.SaveChanges();
 }
Exemplo n.º 7
0
        public IActionResult DeletePcStorage(PcStorageDto pcStorag)
        {
            this.componentService.DeletePcStorage(pcStorag);

            return(RedirectToAction("ShowPcStorages", "PcStorage"));
        }