コード例 #1
0
        public async Task UpdatePrestation(Prestation prestationToBeUpdate, Prestation newPrestation)
        {
            try
            {
                prestationToBeUpdate.Description = newPrestation.Description;
                prestationToBeUpdate.Duration    = newPrestation.Duration;
                prestationToBeUpdate.Price       = newPrestation.Price;
                prestationToBeUpdate.Title       = newPrestation.Title;
                var spec = new IsPrestationCategoryExistSpecification(newPrestation.PrestationCategoryId.ToString());

                bool isCategoryExist = await _unitOfWork.Prestations.IsPrestationCategoryExistAsync(spec);

                if (!isCategoryExist)
                {
                    throw new CategoryDoesNotExistException();
                }

                prestationToBeUpdate.PrestationCategory = newPrestation.PrestationCategory;

                await _unitOfWork.CommitAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #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 <Prestation> CreatePrestation(Prestation newPrestation)
        {
            try
            {
                var  spec            = new IsPrestationCategoryExistSpecification(id: newPrestation.PrestationCategoryId.ToString());
                bool isCategoryExist = await _unitOfWork.Prestations.IsPrestationCategoryExistAsync(spec);

                if (!isCategoryExist)
                {
                    throw new CategoryDoesNotExistException();
                }
                await _unitOfWork.Prestations.AddAsync(newPrestation);

                await _unitOfWork.CommitAsync();

                return(newPrestation);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
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;
            }
        }