public async Task <ActionResult <GearDTO> > GetGear(long id) { var gear = await _repository.GetByIdAsync(id); if (gear == null) { return(NotFound()); } return(Gear.GearToDTO(gear)); }
public async Task <ActionResult <GearDTO> > CreateGear(GearDTO gearDTO) { Gear gear = new Gear { Name = gearDTO.Name, Description = gearDTO.Description, Brand = gearDTO.Brand, WeightGrams = gearDTO.WeightGrams, LengthMM = gearDTO.LengthMM, WidthMM = gearDTO.WidthMM, DepthMM = gearDTO.DepthMM, Locking = gearDTO.Locking, }; await _repository.AddAsync(gear); return(CreatedAtAction(nameof(GetGear), new { id = gear.Id }, Gear.GearToDTO(gear))); }
public Task <List <GearDTO> > DTOListAsync() { return(_dbContext.Gear .Select(x => Gear.GearToDTO(x)) .ToListAsync()); }