public async Task DeletePrestationCategory(PrestationCategory prestationCategory) { try { _unitOfWork.Prestations.DeletePrestationCategory(prestationCategory); await _unitOfWork.CommitAsync(); } catch (Exception) { throw; } }
public async Task <PrestationCategory> CreatePrestationCategory(PrestationCategory newPrestationCategory) { try { var spec = new IsPrestationCategoryExistSpecification(name: newPrestationCategory.Name); bool isCategoryAlreadyExist = await _unitOfWork.Prestations.IsPrestationCategoryExistAsync(spec); if (isCategoryAlreadyExist) { throw new CategoryAlreadyExistException(); } await _unitOfWork.Prestations.AddPrestationCategoryAsync(newPrestationCategory); await _unitOfWork.CommitAsync(); return(newPrestationCategory); } catch (Exception) { throw; } }
public async Task <PrestationCategory> UpdatePrestationCategory(PrestationCategory prestationCategoryToBeUpdate, PrestationCategory prestationCategory) { try { var spec = new IsPrestationCategoryExistSpecification(name: prestationCategoryToBeUpdate.Name.ToString()); bool isCategoryExist = await _unitOfWork.Prestations.IsPrestationCategoryExistAsync(spec); if (!isCategoryExist) { throw new CategoryDoesNotExistException(); } prestationCategoryToBeUpdate.Name = prestationCategory.Name; await _unitOfWork.CommitAsync(); return(prestationCategoryToBeUpdate); } catch (Exception ex) { throw ex; } }
public void DeletePrestationCategory(PrestationCategory prestationCategory) { ElegantGlamourDbContext.PrestationCategories.Remove(prestationCategory); }
public async Task AddPrestationCategoryAsync(PrestationCategory prestationCategory) { await ElegantGlamourDbContext.PrestationCategories.AddAsync(prestationCategory); }