Example #1
0
        public async Task <ActionResult> CreatePost(CreatePostViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var newPost = new Post
            {
                AltImage       = model.AltImage,
                Category       = model.Category,
                CreateData     = DateTime.Now,
                Description    = model.Description,
                imageName      = await _services.UploadImage(model.Image),
                Tags           = model.Tags,
                Text           = model.Text,
                Title          = model.Title,
                TitleOfBrowser = model.TitleOfBrowser
            };
            await _services.CreatePost(newPost);

            return(Redirect("/"));
        }