예제 #1
0
        public async Task DeletePrestationCategory(PrestationCategory prestationCategory)
        {
            try
            {
                _unitOfWork.Prestations.DeletePrestationCategory(prestationCategory);

                await _unitOfWork.CommitAsync();
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
 public void DeletePrestationCategory(PrestationCategory prestationCategory)
 {
     ElegantGlamourDbContext.PrestationCategories.Remove(prestationCategory);
 }
예제 #5
0
 public async Task AddPrestationCategoryAsync(PrestationCategory prestationCategory)
 {
     await ElegantGlamourDbContext.PrestationCategories.AddAsync(prestationCategory);
 }