public void DeleteRam(RamDto ram)
        {
            var ramToDelete = this.context.rams.FirstOrDefault(c => c.model == ram.model);

            this.context.rams.Remove(ramToDelete);

            this.context.SaveChanges();
        }
Ejemplo n.º 2
0
 public IActionResult AddRam(RamDto ram)
 {
     if (ModelState.IsValid)
     {
         componentService.CreateRam(ram);
         return(RedirectToAction(nameof(AddRam)));
     }
     return(View());
 }
 public RAM OfRamDto(RamDto ram)
 {
     return(new RAM()
     {
         model = ram.model,
         frequency = ram.frequency,
         memorysize = ram.memorysize,
         price = ram.price
     });
 }
        public RamDto GetRamById(string id)
        {
            RamDto ramDto = new RamDto();
            RAM    ram    = this.context.rams.FirstOrDefault(x => x.model == id);


            ramDto.model      = ram.model;
            ramDto.frequency  = ram.frequency;
            ramDto.memorysize = ram.memorysize;
            ramDto.price      = ram.price;

            return(ramDto);
        }
Ejemplo n.º 5
0
 public IActionResult AddRam(RamDto ram)
 {
     if (ModelState.IsValid)
     {
         if (componentService.HasTheSameIdInBase(ram.model))
         {
             return(NotFound("A ram with the same model already exits"));
         }
         componentService.CreateRam(ram);
         return(RedirectToAction(nameof(AddRam)));
     }
     return(View());
 }
 public void CreateRam(RamDto ram)
 {
     this.context.rams.Add(this.OfRamDto(ram));
     this.context.SaveChanges();
 }
Ejemplo n.º 7
0
        public IActionResult DeleteRam(RamDto ram)
        {
            this.componentService.DeleteRam(ram);

            return(RedirectToAction("ShowRams", "Ram"));
        }