public async Task <ActionResult> InsertMatchTypes(BilliardsMatchTypeDto dto) { var type = await unitOfWork.BilliardsMatchTypesRepository.GetMatchTypeByNameAsync(dto.Type); if (type != null) { return(BadRequest("Already exists!")); } unitOfWork.BilliardsMatchTypesRepository.InsertMatchType(mapper.Map <BilliardsMatchType>(dto)); if (await unitOfWork.Complete()) { return(NoContent()); } return(BadRequest("Insert failed!")); }
public async Task <ActionResult> UpdateMatchTypes(BilliardsMatchTypeDto dto) { var type = await unitOfWork.BilliardsMatchTypesRepository.GetMatchTypeByIdAsync(dto.Id); if (type == null) { return(BadRequest("Type does not exists!")); } mapper.Map(dto, type); unitOfWork.BilliardsMatchTypesRepository.UpdateMatchType(type); if (await unitOfWork.Complete()) { return(NoContent()); } return(BadRequest("Updated failed")); }