Beispiel #1
0
        public async Task <CardItemInfo> CreateAsync(CardItem cardToCreate, CancellationToken cancellationToken)
        {
            await context.Cards.AddAsync(cardToCreate);

            await context.SaveChangesAsync();

            return(cardToCreate);
        }
        public async Task <UserInfo> CreateAsync(User userToCreate, CancellationToken cancellationToken)
        {
            await context.Users.AddAsync(userToCreate);

            await context.SaveChangesAsync();

            return(userToCreate);
        }
        public async Task <CardsCollection> CreateAsync(CardsCollection collectionToAdd)
        {
            await context.Collections.AddAsync(collectionToAdd);

            await context.SaveChangesAsync();

            return(collectionToAdd);
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("Name,Id")] WorkItemState workItemState)
        {
            if (ModelState.IsValid)
            {
                _context.Add(workItemState);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(workItemState));
        }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("Name,CreatedAt,Id")] User user)
        {
            if (ModelState.IsValid)
            {
                user.CreatedAt = DateTime.Now;
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
        public async Task <bool> AddAsync(PasswordResetToken token)
        {
            try
            {
                await context.PasswordResetTokens.AddAsync(token);

                await context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(true);
        }
Beispiel #7
0
        public async Task <Training> AddAsync(Training training)
        {
            await context.Trainings.AddAsync(training);

            await context.SaveChangesAsync();

            return(training);
        }
Beispiel #8
0
        public async Task <DeleteMovieSuccessResponse> Handle(DeleteMovieCommand request, CancellationToken cancellationToken)
        {
            var movie = await _context.Movies.FirstOrDefaultAsync(x => x.MovieId == request.MovieId,
                                                                  cancellationToken);

            if (movie == null)
            {
                return(null);
            }
            _context.Movies.Remove(movie);
            await _context.SaveChangesAsync(cancellationToken);

            return(new DeleteMovieSuccessResponse(request.MovieId));
        }
Beispiel #9
0
        public async Task <PatchMovieSuccessResponse> Handle(PatchMovieCommand request, CancellationToken cancellationToken)
        {
            var movie = _context.Movies.FirstOrDefault(x => x.MovieId == request.MovieId);

            if (movie == null)
            {
                return(null);
            }

            movie.Title          = request.Title;
            movie.Price          = request.Price;
            movie.Year           = request.Year;
            movie.AgeRestriction = request.AgeRestriction;
            await _context.SaveChangesAsync(cancellationToken);

            return(new PatchMovieSuccessResponse(request.MovieId));
        }
Beispiel #10
0
        public async Task <PostMovieSuccessResponse> Handle(PostMovieCommand request,
                                                            CancellationToken cancellationToken)
        {
            var movie = new Movie
            {
                Title          = request.Title,
                Year           = request.Year,
                AgeRestriction = request.AgeRestriction,
                Price          = request.Price
            };

            await _context.Movies.AddAsync(movie, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            return(new PostMovieSuccessResponse(request.Title));
        }