public async Task <ActionResult <string> > RequestDeleteUser(string FacebookId) { // required for FB privacy policy. We also ban if this happens. // do we have user with this id - ours? Users existUser = await(from u in _context.Users where u.FbId == FacebookId select u).FirstOrDefaultAsync(); if (existUser is null) { return(NotFound("User ID not found")); } existUser.BanFlag = true; existUser.DeleteRequestedTms = DateTime.UtcNow; var newBan = new BanListText() { FirstNm = existUser.FirstNm, LastNm = existUser.LastNm, CityNm = existUser.CityNm, StateCd = existUser.StateCd, CommentTxt = "User requested deletion of data and is banned from CR." }; await _context.BanListText.AddAsync(newBan); await _context.SaveChangesAsync(); return(Ok("You have requested deletion of your data. You have been removed from the Computer Reset signup system and do not have permission to sign up for an event.")); }
public async Task <ActionResult <string> > AdminUserId(BanListForm banList) { //manually edits the ban user text list if (!CheckAdmin()) { return(Unauthorized("You are not permitted to use this function.")); } //do we have user with this id - ours? BanListText banText = await(from b in _context.BanListText where b.Id == banList.Id select b).SingleOrDefaultAsync(); if (banText == null) { banText = new BanListText() { //assume new input FirstNm = banList.FirstNm, LastNm = banList.LastNm, CityNm = banList.CityNm, StateCd = banList.StateCd, CommentTxt = banList.CommentTxt }; _context.BanListText.Add(banText); await _context.SaveChangesAsync(); return(Ok("This user was added to the manual ban list.")); } else { //we have a response so update banText.FirstNm = banList.FirstNm; banText.LastNm = banList.LastNm; banText.CityNm = banList.CityNm; banText.StateCd = banList.StateCd; banText.CommentTxt = banList.CommentTxt; await _context.SaveChangesAsync(); return(Ok("This user was updated on the manual ban list.")); } }