//[ValidateAntiForgeryToken] public async Task <IActionResult> Create([Bind("id,title,description")] Post post) { if (ModelState.IsValid) { Owner user_Session = um.GetUser_Session(Request); post.date_created = DateTime.Now; post.owner = user_Session; post.modify_date = DateTime.Now; var path = _env.WebRootPath; var uploads = Path.Combine(path, "img"); List <VideoImage> VideoImages = new List <VideoImage>(); var files = HttpContext.Request.Form.Files; foreach (IFormFile file in files) { string extension = System.IO.Path.GetExtension(file.FileName); string _id = ObjectId.GenerateNewId().ToString(); await save_fileAsync(_id + extension, uploads, file); VideoImage videoImage = new VideoImage { _id = _id, type = extension, link = "/img/" + _id + extension }; VideoImages.Add(videoImage); } post.video_image = VideoImages; await pm.insertPostAsync(post); return(Ok(new { Message = "Post created sucessfully" })); } return(BadRequest(new { Message = "Please fill all fields" })); }