public async Task <IActionResult> Process(HomeViewModel model) { User user = await _auth.getUserAsync(); if (ModelState.IsValid) { List <File> files = _db.Files.Where(f => f.response.User.email == user.email).ToList(); foreach (File f in files) { _db.Files.Remove(f); } List <Response> responses = _db.Responses.Where(r => r.client.User.email == user.email).ToList(); foreach (Response r in responses) { _db.Responses.Remove(r); } _db.SaveChanges(); int i = 0; foreach (Client c in _db.Clients.Where(c => c.active == true && c.User == user).ToList()) { _db.Requests.Add(new Request() { fileName = model.filename, client = c, User = user }); i++; } _db.SaveChanges(); ViewData["neededResponses"] = i; return(View()); } return(View("Index", model)); }
public async Task <IActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { _db.Users.Add(new User(model)); _db.SaveChanges(); _auth.signIn(new User(model)); return(Redirect("/")); } return(View(model)); }
public async Task <bool> DeleteFiles() { User user = await _auth.getUserAsync(); List <File> files = _db.Files.Where(f => f.response.User.email == user.email).ToList(); foreach (File f in files) { _db.Files.Remove(f); } _db.SaveChanges(); return(true); }