Esempio n. 1
0
        public async Task <ActionResult> EditePost(EditePostViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var post = await _services.GetPost(model.id);

            if (post == null)
            {
                return(NotFound());
            }
            if (model.NewImage != null)
            {
                _services.DeleteImage(post.imageName);
                post.imageName = await _services.UploadImage(model.NewImage);
            }
            post.Title       = model.Title;
            post.Description = model.Description;
            post.AltImage    = model.AltImage;
            post.Text        = model.Text;
            post.Tags        = model.Tages;
            post.Category    = model.Category;
            await _services.UpdatePost(post);

            return(Redirect("/"));
        }