Beispiel #1
0
        public IActionResult Add(AddContentViewModel model)
        {
            if (ModelState.IsValid)
            {
                var result = _commandDispatcher.Dispatch(new AddContentCommand()
                {
                    Description = model.Description,
                    Title       = model.Title,
                    Body        = model.Body,
                    CategoryId  = model.CategoryId,
                    PublishDate = model.PublishDate,
                    WriterId    = _queryDispatcher.Dispatch <long>(new GetWriterIdQuery()
                    {
                        WriterName = User.Identity.Name
                    }),
                    Rate            = model.Rate,
                    PublishPlacesId = model.PublishPlacesId,
                    KeywordsId      = model.KeywordsId,
                    PhotoId         = model.ContentPhotoId,
                });

                if (result.IsSuccess)
                {
                    return(RedirectToAction(nameof(List)));
                }
                AddCommadErrorsToModelState(result);
            }
            model.AllCategories    = _queryDispatcher.Dispatch <List <Category> >(new GetCategoriesQuery());
            model.AllKeywords      = _queryDispatcher.Dispatch <List <Keyword> >(new GetKeywordsQuery());
            model.AllPublishPlaces = _queryDispatcher.Dispatch <List <PublishPlace> >(new GetPlacesQuery());

            return(View(model));
        }
Beispiel #2
0
        public IActionResult Add()
        {
            var model = new AddContentViewModel();

            model.AllCategories    = _queryDispatcher.Dispatch <List <Category> >(new GetCategoriesQuery());
            model.AllKeywords      = _queryDispatcher.Dispatch <List <Keyword> >(new GetKeywordsQuery());
            model.AllPublishPlaces = _queryDispatcher.Dispatch <List <PublishPlace> >(new GetPlacesQuery());
            model.AllPhotos        = _queryDispatcher.Dispatch <List <DtoPhotoList> >(new GetPhotosQuery());

            return(View(model));
        }
Beispiel #3
0
        public async Task <IActionResult> Add()
        {
            var categories = await _categoryManager.GetAll();

            AddContentViewModel model = new AddContentViewModel
            {
                Content    = new Content(),
                Categories = categories
            };

            return(View(model));
        }
Beispiel #4
0
        //
        // GET: /ManageContent/

        public ActionResult Index(int?page)
        {
            var pageNumber = page ?? 1;
            int size       = 10;

            AddContentModel addContentModel = new AddContentModel();

            AddContentViewModel viewModel = new AddContentViewModel();

            viewModel.UserContents = addContentModel.GetAllAddContent(pageNumber, size);

            return(View(viewModel));
        }
Beispiel #5
0
        public async Task <IActionResult> Add(Content content)
        {
            if (!ModelState.IsValid)
            {
                var categories = await _categoryManager.GetAll();

                AddContentViewModel model = new AddContentViewModel
                {
                    Content    = new Content(),
                    Categories = categories
                };
                return(View(model));
            }
            await _contentManager.Add(content);

            TempData["message"] = "Yeni İçerik Eklendi";
            return(RedirectToAction("List"));
        }
        public async Task <IActionResult> Create(AddContentViewModel model)
        {
            var username = this.User.Identity.Name;

            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            var succes = await this.service.Create(model.Title, model.Text, model.Type, username);

            if (succes)
            {
                this.ViewData[ContentConst.SUCCESS] = ContentConst.ADD_SUCCESS;
                return(this.RedirectToAction(nameof(Index)));
            }

            return(this.View(model));
        }
        public IActionResult Create(AddContentViewModel addContent)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (_conService.AddContent(addContent, _env))
                    {
                        return(RedirectToAction(nameof(Index)));
                    }

                    return(View("Error", new ErrorViewModel {
                        RequestId = "Unable to perform your request"
                    }));
                }
                catch
                {
                    return(View("Error", new ErrorViewModel {
                        RequestId = "Unable to perform your request"
                    }));
                }
            }
            return(View());
        }