public async Task Delete(WaistDto dto) { var waist = await _waistRepository.GetById(dto.Id); if (waist != null) { var delete = await _waistRepository.GetById(waist.Id); if (delete.ErasedState) { delete.ErasedState = false; await _waistRepository.Update(delete); } else { delete.ErasedState = true; await _waistRepository.Update(delete); } } else { throw new Exception("This Waist not exist"); } }
public async Task Create(WaistDto dto) { var waist = new Domain.Entities.Waist { Description = dto.Description, ColourId = dto.ColourId, ErasedState = false }; await _waistRepository.Create(waist); }
public async Task Update(WaistDto dto) { using (var context = new DataContext()) { var updateWaist = context.Waists.FirstOrDefault(x => x.Id == dto.Id); if (updateWaist == null) { throw new Exception("The Waist to modify was not found"); } else { if (updateWaist.ErasedState) { throw new Exception("The Waist is eliminated"); } updateWaist.Description = dto.Description; updateWaist.ColourId = dto.ColourId; await _waistRepository.Update(updateWaist); } } }