public async Task <IActionResult> AcceptShare(int id) { ApplicationUser user = await GetCurrentUserAsync(); SharedDependent remove = await _context.SharedDependent .Where(sd => sd.DependentUserId == id && sd.ToUser == user) .SingleOrDefaultAsync(); DependentUser DependentUser = new DependentUser { DependentId = id, User = user, }; _context.Add(DependentUser); await _context.SaveChangesAsync(); _context.Remove(remove); await _context.SaveChangesAsync(); // SharedDependent Remove = RemoveFromShareTable(id); //return RedirectToAction("RemoveShared", new { id = id }); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, [Bind("SharedDependentId,DependentUserId")] SharedDependent sharedDependent) { if (id != sharedDependent.SharedDependentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sharedDependent); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SharedDependentExists(sharedDependent.SharedDependentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DependentUserId"] = new SelectList(_context.DependentUser, "DependentUserId", "UserId", sharedDependent.DependentUserId); return(View(sharedDependent)); }
public async Task <IActionResult> RejectShare(int id) { SharedDependent DeleteShare = await _context.SharedDependent .Where(d => d.SharedDependentId == id) .SingleOrDefaultAsync(); _context.Remove(DeleteShare); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(string ToUserEmail, int DependentId) { //string normalized = ToUserEmail.ToUpper(); ApplicationUser toUser = await _context.Users.Where(u => u.UserName == ToUserEmail).FirstOrDefaultAsync(); var SharedDependent = new SharedDependent { ToUser = toUser, DependentUserId = DependentId }; if (toUser == null) { ModelState.AddModelError("ToUserEmail", "That User Does Not Exist"); return(RedirectToAction(nameof(Index))); } _context.Add(SharedDependent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }