Exemplo n.º 1
0
        public async Task DeletePrestationCategory(PrestationCategory prestationCategory)
        {
            try
            {
                _unitOfWork.Prestations.DeletePrestationCategory(prestationCategory);

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