Пример #1
0
        public async Task ChangeIngridientStatusAsync(string userId, int id)
        {
            var ingridient = await _repositoryIngridient
                             .GetEntityAsync(ingridient =>
                                             ingridient.Id == id && ingridient.UserId == userId);

            if (ingridient is null)
            {
                throw new KeyNotFoundException(ErrorResource.IngridientNotFound);
            }

            _repositoryIngridient.Update(ingridient);
            await _repositoryIngridient.SaveChangesAsync();
        }
Пример #2
0
        public async Task ChangeReadyMealStatusAsync(string userId, int id)
        {
            var readymeal = await _repositoryReadyMeal
                            .GetEntityAsync(readymeal =>
                                            readymeal.Id == id && readymeal.UserId == userId);

            if (readymeal is null)
            {
                throw new KeyNotFoundException(ErrorResource.ReadyMealNotFound);
            }

            _repositoryReadyMeal.Update(readymeal);
            await _repositoryReadyMeal.SaveChangesAsync();
        }
Пример #3
0
        public async Task UpdateOrderStatusByIdAsync(int orderId, StatusType statusType)
        {
            var order = await _orderRepository
                        .GetEntityAsync(o => o.Id == orderId);

            if (order is null)
            {
                throw new KeyNotFoundException(nameof(order));
            }

            order.Status = statusType;

            await _orderRepository.SaveChangesAsync();
        }
Пример #4
0
        public async Task UpdateProfileAsync(ProfileDto profileDto)
        {
            profileDto = profileDto ?? throw new ArgumentNullException(nameof(profileDto));

            var profile = await _profileRepository.GetEntityAsync(p => p.UserId == profileDto.UserId);

            profile.Name      = profileDto.Name;
            profile.Gender    = profileDto.Gender;
            profile.BirthDate = profileDto.BirthDate;
            profile.Address   = profileDto.Address;

            if (profileDto.Avatar is not null)
            {
                profile.Avatar = profileDto.Avatar;
            }

            await _profileRepository.SaveChangesAsync();
        }
Пример #5
0
 public async Task UpdateProfileAsync(ProfileDto profileDto)
 {
     if (profileDto != null)
     {
         var userProfile = await _repositoryProfile.GetEntityAsync(pr => pr.UserId == profileDto.UserId);