public void DeleteMotherboard(MotherboardDto motherboard)
        {
            var motherboardToDelete = this.context.motherboards.FirstOrDefault(c => c.model == motherboard.model);

            this.context.motherboards.Remove(motherboardToDelete);

            this.context.SaveChanges();
        }
Exemplo n.º 2
0
 public IActionResult AddMotherboard(MotherboardDto motherboard)
 {
     if (ModelState.IsValid)
     {
         componentService.CreateMotherboard(motherboard);
         return(RedirectToAction(nameof(motherboard)));
     }
     return(View());
 }
 public Motherboard OfMotherboardDto(MotherboardDto motherboard)
 {
     return(new Motherboard()
     {
         model = motherboard.model,
         socket = motherboard.socket,
         ramSlots = motherboard.ramSlots,
         formfactor = motherboard.formfactor,
         sliCrossfireSuport = motherboard.sliCrossfireSuport,
         suportedGeneration = motherboard.suportedGeneration,
         price = motherboard.price
     });
 }
 public IActionResult AddMotherboard(MotherboardDto motherboard)
 {
     if (ModelState.IsValid)
     {
         if (componentService.HasTheSameIdInBase(motherboard.model))
         {
             return(NotFound("A motherboard with the same model already exits"));
         }
         componentService.CreateMotherboard(motherboard);
         return(RedirectToAction(nameof(ShowMotherboards)));
     }
     return(View());
 }
        public MotherboardDto GetMotherboardById(string id)
        {
            MotherboardDto motherboardDto = new MotherboardDto();
            Motherboard    motherboard    = this.context.motherboards.FirstOrDefault(x => x.model == id);

            motherboardDto.model              = motherboard.model;
            motherboardDto.socket             = motherboard.socket;
            motherboardDto.ramSlots           = motherboard.ramSlots;
            motherboardDto.formfactor         = motherboard.formfactor;
            motherboardDto.sliCrossfireSuport = motherboard.sliCrossfireSuport;
            motherboardDto.suportedGeneration = motherboard.suportedGeneration;
            motherboardDto.price              = motherboard.price;

            return(motherboardDto);
        }
 public void CreateMotherboard(MotherboardDto motherboard)
 {
     this.context.motherboards.Add(this.OfMotherboardDto(motherboard));
     this.context.SaveChanges();
 }
        public IActionResult DeleteMotherboard(MotherboardDto component)
        {
            this.componentService.DeleteMotherboard(component);

            return(RedirectToAction("ShowMotherboards", "Motherboard"));
        }