public async Task <IActionResult> PutComments(int id, Comments comments) { if (id != comments.Id) { return(BadRequest()); } _context.Entry(comments).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAspNetUsers(string id, AspNetUsers aspNetUsers) { if (id != aspNetUsers.Id) { return(BadRequest()); } _context.Entry(aspNetUsers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AspNetUsersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> Index() { string fileName = "temp.zip"; string sourcePath = @"W:\\_web\\wileyknight\\ClientResources\\"; //string sourcePath = Path.Combine(Directory.GetCurrentDirectory(), "ClientResources"); FormValueProvider formModel; using (var stream = System.IO.File.Create(sourcePath + fileName)) { formModel = await Request.StreamFile(stream); } var viewModel = new Assets(); var bindingSuccessful = await TryUpdateModelAsync(viewModel, prefix : "", valueProvider : formModel); if (!bindingSuccessful) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } } _context.Assets.Add(viewModel); await _context.SaveChangesAsync(); string targetPath = @"W:\\_web\\wileyknight\\ClientResources\\" + viewModel.FileLocation + "\\"; //string targetPath = Path.Combine(sourcePath, viewModel.FileLocation); // Use Path class to manipulate file and directory paths. string sourceFile = Path.Combine(sourcePath, fileName); string destFile = Path.Combine(targetPath, viewModel.FileName); // To copy a folder's contents to a new location: // Create a new target folder. // If the directory already exists, this method does not create a new directory. Directory.CreateDirectory(targetPath); // To copy a file to another location and // overwrite the destination file if it already exists. System.IO.File.Copy(sourceFile, destFile, true); return(CreatedAtAction("Index", new { id = viewModel.Id }, viewModel)); }