public async Task<IActionResult> Rename([FromForm]Tutorial tutorial) { if (ModelState.IsValid) { IFormFile file = Request.Form.Files["UploadedFile"]; var name = Request.Form["UploadedFileName"]; var id = Request.Form["UploadedFileID"]; var path = Request.Form["UploadedFilePath"]; if (file != null) { if (!Directory.Exists(_environment.WebRootPath + "\\video\\")) { Directory.CreateDirectory(_environment.WebRootPath + "\\video\\"); } using (FileStream fileStream = System.IO.File.Create(_environment.WebRootPath + "\\video\\" + file.FileName)) { file.CopyTo(fileStream); fileStream.Flush(); tutorial.ID = id.ToInt(); var item = await _tutorialService.FindItem(tutorial.ID); item.Name = name; item.Path = path; item.URL = _configuaration["AppSettings:applicationUrl"] + $"/video/{file.FileName}"; //return "\\image\\" + file.FileName; await _tutorialService.Save(); } } else { tutorial.ID = id.ToInt(); var item = await _tutorialService.FindItem(tutorial.ID); item.Name = name; item.Path = path; await _tutorialService.Save(); } //_context.Add(entity); //await _context.SaveChangesAsync(); return Ok(tutorial); } else { var errors = ModelState.Values.SelectMany(v => v.Errors); } return Ok(tutorial); }