public async Task <IActionResult> UpdateStatus(ErrandStatus errandStatus, int errandID, string events, string information, IFormFile loadSample, IFormFile loadImage) { repository.UpdateStatus(errandID, errandStatus.StatusId, events, information); var tempPath = Path.GetTempFileName(); if (loadSample != null && loadSample.Length > 0) { using (var stream = new FileStream(tempPath, FileMode.Create)) { await loadSample.CopyToAsync(stream); } string uniqueFileName = Guid.NewGuid().ToString() + "_" + loadSample.FileName; var path = Path.Combine(environment.WebRootPath, "SampleFIles", uniqueFileName); System.IO.File.Move(tempPath, path); repository.AddSampleFile(uniqueFileName, errandID); } if (loadImage != null && loadImage.Length > 0) { using (var stream = new FileStream(tempPath, FileMode.Create)) { await loadImage.CopyToAsync(stream); } string uniqueFileName = Guid.NewGuid().ToString() + "_" + loadImage.FileName; var path = Path.Combine(environment.WebRootPath, "ImageFiles", uniqueFileName); System.IO.File.Move(tempPath, path); repository.AddImageFile(uniqueFileName, errandID); } return(View("StartInvestigator", repository)); }