Exemplo n.º 1
0
        public async Task <int> CreateOrderAsync(OrderDto orderDto)
        {
            orderDto = orderDto ?? throw new ArgumentNullException(nameof(orderDto));

            var order = new Order
            {
                Number     = orderDto.Number,
                Creation   = orderDto.Creation,
                UserId     = orderDto.UserId,
                Name       = orderDto.Name,
                Phone      = orderDto.Phone,
                InPlace    = orderDto.InPlace,
                Address    = orderDto.Address,
                PromoCode  = orderDto.PromoCode,
                TotalPrice = orderDto.TotalPrice,
                Payment    = orderDto.Payment,
                Comment    = orderDto.Comment,
                Status     = orderDto.Status,
            };

            await _orderRepository.CreateAsync(order);

            await _orderRepository.SaveChangesAsync();

            return(order.Id);
        }
        public async Task <IActionResult> Post([FromBody] ParentRequest model)
        {
            var parentModel = new ParentModel
            {
                StringVar = model.StringVar,
            };

            await _parentRepositoryManager.CreateAsync(parentModel);

            await _parentRepositoryManager.SaveChangesAsync();

            return(Ok());
        }
Exemplo n.º 3
0
        public async Task CreateProfileAsync(ProfileDto profileDto)
        {
            var profile = new Profile
            {
                Id             = profileDto.Id,
                UserId         = profileDto.UserId,
                FirstName      = profileDto.FirstName,
                LastName       = profileDto.LastName,
                MiddleName     = profileDto.MiddleName,
                BirthDate      = profileDto.BirthDate,
                Phone          = profileDto.Phone,
                Telegram       = profileDto.Telegram,
                SocialNetwork  = profileDto.SocialNetwork,
                ProfilePicture = profileDto.ProfilePicture,
            };
            //Create new model
            await _repositoryProfile.CreateAsync(profile);

            //Save new model in DataBase
            await _repositoryProfile.SaveChangesAsync();
        }
Exemplo n.º 4
0
        public async Task CreateProfileAsync(string userId, string name)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentException($"'{nameof(userId)}' cannot be null or empty.", nameof(userId));
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException($"'{nameof(name)}' cannot be null or empty.", nameof(name));
            }

            var profile = new Profile
            {
                UserId = userId,
                Name   = name,
            };

            await _profileRepository.CreateAsync(profile);

            await _profileRepository.SaveChangesAsync();
        }
Exemplo n.º 5
0
        public async Task CreateAsync(ReadyMealDto readyMealDto)
        {
            if (readyMealDto is null)
            {
                throw new ArgumentNullException(nameof(readyMealDto));
            }

            var readymeal = new ReadyMeal
            {
                Id            = readyMealDto.Id,
                UserId        = readyMealDto.UserId,
                Name          = readyMealDto.Name,
                ChildReacrion = readyMealDto.ChildReacrion,
                TeastyMeal    = readyMealDto.TeastyMeal,
                Comment       = readyMealDto.Comment,
                ReadyTime     = readyMealDto.ReadyTime,
                Picture       = readyMealDto.Picture,
            };
            await _repositoryReadyMeal.CreateAsync(readymeal);

            await _repositoryReadyMeal.SaveChangesAsync();
        }
Exemplo n.º 6
0
        public async Task CreateAsync(IngridientDto ingridientDto)
        {
            if (ingridientDto is null)
            {
                throw new ArgumentNullException(nameof(ingridientDto));
            }

            var ingridient = new Ingridient
            {
                Id           = ingridientDto.Id,
                UserId       = ingridientDto.UserId,
                Name         = ingridientDto.Name,
                Category     = ingridientDto.Category,
                IsVeggie     = ingridientDto.IsVeggie,
                Description  = ingridientDto.Description,
                Colories     = ingridientDto.Colories,
                IsRecomended = ingridientDto.IsRecomended,
                ReactionType = ingridientDto.ReactionType,
                Date         = ingridientDto.Date
            };
            await _repositoryIngridient.CreateAsync(ingridient);

            await _repositoryIngridient.SaveChangesAsync();
        }
Exemplo n.º 7
0
 public async Task <T> Create(T collection)
 {
     return(await manager.CreateAsync(collection));
 }