Beispiel #1
0
        public async Task <IngridientDto> GetIngridientAsync(int id, string userId)
        {
            var ingridient = await _repositoryIngridient
                             .GetEntityWithoutTrackingAsync(ingridient =>
                                                            ingridient.Id == id && ingridient.UserId == userId);

            if (ingridient is null)
            {
                throw new ArgumentNullException(nameof(ingridient));
            }

            var ingridientDto = new IngridientDto
            {
                Id           = ingridient.Id,
                UserId       = ingridient.UserId,
                Name         = ingridient.Name,
                Category     = ingridient.Category,
                IsVeggie     = ingridient.IsVeggie,
                Description  = ingridient.Description,
                Colories     = ingridient.Colories,
                IsRecomended = ingridient.IsRecomended,
                ReactionType = ingridient.ReactionType,
                Date         = ingridient.Date
            };

            return(ingridientDto);
        }
Beispiel #2
0
        public async Task <ReadyMealDto> GetReadyMealAsync(int id, string userId)
        {
            var readymeal = await _repositoryReadyMeal
                            .GetEntityWithoutTrackingAsync(readymeal =>
                                                           readymeal.Id == id && readymeal.UserId == userId);

            if (readymeal is null)
            {
                throw new ArgumentNullException(nameof(readymeal));
            }

            var readyMealDto = new ReadyMealDto
            {
                Id            = readymeal.Id,
                UserId        = readymeal.UserId,
                Name          = readymeal.Name,
                ChildReacrion = readymeal.ChildReacrion,
                TeastyMeal    = readymeal.TeastyMeal,
                Comment       = readymeal.Comment,
                ReadyTime     = readymeal.ReadyTime,
                Picture       = readymeal.Picture,
            };

            return(readyMealDto);
        }
        public async Task <IActionResult> Put(int id, [FromBody] ParentRequest model)
        {
            var parentModel =
                await _parentRepositoryManager
                .GetEntityWithoutTrackingAsync(parentModel => parentModel.Id == id);

            if (parentModel is null)
            {
                return(NotFound());
            }

            parentModel.StringVar = model.StringVar;
            _parentRepositoryManager.Update(parentModel);
            await _parentRepositoryManager.SaveChangesAsync();

            return(Ok());
        }
Beispiel #4
0
        public async Task <PromoCodeDto> GetPromoCodeByCodeAsync(string code)
        {
            code = code ?? throw new ArgumentException($"'{nameof(code)}' cannot be null or empty.", nameof(code));

            var promoCode = await _promoCodeRepository
                            .GetEntityWithoutTrackingAsync(promo => promo.Code == code.ToUpper());

            return(promoCode is null
                ? new PromoCodeDto()
                : new PromoCodeDto
            {
                Id = promoCode.Id,
                Code = promoCode.Code,
                Value = promoCode.Value,
                Comment = promoCode.Comment,
            });
        }
Beispiel #5
0
        public async Task <ProfileDto> GetProfileByUserIdAsync(string userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentException($"'{nameof(userId)}' cannot be null or empty.", nameof(userId));
            }

            var profile = await _profileRepository.GetEntityWithoutTrackingAsync(p => p.UserId == userId);

            return(new ProfileDto
            {
                UserId = profile.UserId,
                Name = profile.Name,
                Gender = profile.Gender,
                BirthDate = profile.BirthDate,
                Address = profile.Address,
                Avatar = profile.Avatar,
            });
        }
Beispiel #6
0
        public async Task <ProfileDto> GetProfileAsync(int id, string userId)
        {
            var profile = await _repositoryProfile
                          .GetEntityWithoutTrackingAsync(profile =>
                                                         profile.Id == id && profile.UserId == userId);

            var profileDto = new ProfileDto
            {
                Id             = profile.Id,
                UserId         = profile.UserId,
                FirstName      = profile.FirstName,
                LastName       = profile.LastName,
                MiddleName     = profile.MiddleName,
                BirthDate      = profile.BirthDate,
                Phone          = profile.Phone,
                Telegram       = profile.Telegram,
                SocialNetwork  = profile.SocialNetwork,
                ProfilePicture = profile.ProfilePicture,
            };

            return(profileDto);
        }
        public async Task <OrderDto> GetByIdAsync(int id)
        {
            var order = await _orderRepository.GetEntityWithoutTrackingAsync(o => o.Id == id);

            return(GetOrder(order));
        }