Exemplo n.º 1
0
        public OperationResult Edit(EditSlide command)
        {
            var operation = new OperationResult();
            var slide     = _slideRepository.Get(command.Id);

            if (slide == null)
            {
                return(operation.Failed(ApplicationMessages.RecordNotFound));
            }
            slide.Edit(command.Picture, command.PictureAlt, command.PictureTitle, command.Heading, command.Text, command.Title, command.Link, command.BtnText);
            _slideRepository.SaveChanges();
            return(operation.Succeded());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ExecuteAsync(int slideId, SaveSlide saveSlide, CancellationToken cancellationToken)
        {
            var slide = await _slideRepository.Get(slideId, cancellationToken);

            if (slide == null)
            {
                return(new NotFoundResult());
            }
            _saveSlideToSlideMapper.Map(saveSlide, slide);

            //var user = _httpContextAccessor.HttpContext.User;
            //if (user == null)
            //    return new NotFoundResult();

            //var claims = user.Claims.ToList();
            //if (claims.Count < 1)
            //    return new NotFoundResult();
            //// Lấy Id của người dùng
            //var userId = claims.FirstOrDefault(claimRecord => claimRecord.Type == "sub")?.Value;

            //slide.ModifiedBy = userId;

            slide = await _slideRepository.Update(slide, cancellationToken);

            var slideViewModel = _slideToSlideMapper.Map(slide);

            return(new OkObjectResult(slideViewModel));
        }
Exemplo n.º 3
0
        public OperationResult Edit(EditSlide command)
        {
            var result = new OperationResult();
            var slide  = _slideRepository.Get(command.Id);

            if (slide == null)
            {
                return(result.Failed(QueryValidationMessage.NotFound));
            }
            var path        = "Slides";
            var picturePath = _fileUploader.FileUpload(command.Picture, path);

            slide.Edit(picturePath, command.PictureTitle, command.PictureAlt, command.Heading, command.Title,
                       command.Text, command.BtnText, command.Link);
            _slideRepository.SaveChanges();
            return(result.Succeeded());
        }
        public Slide Read(int id)
        {
            try
            {
                var slide = _slideRepository.Get(id);

                if (slide != null)
                {
                    return(slide);
                }

                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> ExecuteAsync(int id, CancellationToken cancellationToken)
        {
            var slide = await _slideRepository.Get(id, cancellationToken);

            if (slide == null)
            {
                return(new NoContentResult());
            }
            var slideViewModels = _slideMapper.Map(slide);

            return(new OkObjectResult(slideViewModels));
        }
Exemplo n.º 6
0
 public SlideInfo GetSlide(string id)
 {
     return(_slideRepository.Get(id));
 }