public async Task <IActionResult> LeaveasAdmin(int groupid) { if (GroupStatus(groupid) == 1) { if (ModelState.IsValid) { try { var gp = await _context.GroupPeople.Where(e => e.GroupId == groupid && e.UserId == User.FindFirstValue(ClaimTypes.NameIdentifier)).Select(x => new { gid = x.Id }).FirstOrDefaultAsync(); GroupPeople groupPeople = new GroupPeople() { Id = gp.gid, Status = 2 }; //var groupp = _context.GroupPeople.Where(e => e.GroupId == id && e.UserId == User.FindFirstValue(ClaimTypes.NameIdentifier)).FirstOrDefault(); _context.Attach(groupPeople); _context.Entry(groupPeople).Property("Status").IsModified = true; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction("GroupAbout", "GroupManagement", new { id = groupid, Messege = "You are no longer an admin now!!" })); } return(View()); } else { return(NotFound()); } }
public async Task <IActionResult> AcceptRequestfromMembers(int id, int GroupId) { if (ModelState.IsValid) { try { GroupPeople groupPeople = new GroupPeople() { Id = id, Status = 2 }; _context.Attach(groupPeople); _context.Entry(groupPeople).Property("Status").IsModified = true; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroupPeopleExists(id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("AddRequestfromMembers", new { id = GroupId })); } return(View()); }
public IActionResult Edit(long id, [Bind("GroupPeopleID,Ref,GroupName,PersonId")] GroupPeople groupPeople) { if (id != groupPeople.GroupPeopleID) { return(NotFound()); } if (ModelState.IsValid) { try { service.Update(groupPeople); } catch (DbUpdateConcurrencyException) { if (!GroupPeopleExists(groupPeople.GroupPeopleID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PersonID"] = new List <SelectListItem>(service.GetSelectListPeople()); return(View(groupPeople)); }
public async Task <IActionResult> AcceptAsAdmin(int GroupId) { if (ModelState.IsValid) { try { var gp = await _context.GroupPeople.Where(e => e.GroupId == GroupId && e.UserId == User.FindFirstValue(ClaimTypes.NameIdentifier)).Select(x => new { GPID = x.Id }).FirstOrDefaultAsync(); GroupPeople groupPeople = new GroupPeople() { Id = gp.GPID, Status = 1 }; //var groupp = _context.GroupPeople.Where(e => e.GroupId == id && e.UserId == User.FindFirstValue(ClaimTypes.NameIdentifier)).FirstOrDefault(); _context.Attach(groupPeople); _context.Entry(groupPeople).Property("Status").IsModified = true; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction("GroupAbout", "GroupManagement", new { id = GroupId, Messege = "Congralutation!! You are an Admin now." })); } return(View()); }
public void Add(GroupPeople groupPeople) { //Go to GroupPeopleRepository, add the new groupPeople and return the (new) GroupPeopleID repository.Add(groupPeople); //Go to AssetOwnerRepository and add a new Owner by adding the GroupPeople(ID) repositoryAssetOwner.AddAssetOwnerGroupPeople(groupPeople.GroupPeopleID); //no need to return anyting, that's why here keep void! }
public IActionResult Create([Bind("GroupPeopleID,Ref,GroupName,PersonId")] GroupPeople groupPeople) { if (ModelState.IsValid) { service.Add(groupPeople); return(RedirectToAction(nameof(Index))); } ViewData["PersonID"] = new List <SelectListItem>(service.GetSelectListPeople()); return(View(groupPeople)); }
public Tuple <long, GroupPeople, List <PersonGroupPeople>, List <Asset> > GetGroupPeopleWithSub(long groupPeopleID) { GroupPeople groupPeople = FindById(groupPeopleID); List <PersonGroupPeople> personGroupPeoples = repositoryPersonGroupPeople.GetAllPeopleOfPersonGroupPeople(groupPeopleID); AssetOwner assetOwner = repositoryAssetOwner.GetAssetOwnerOfGroupePeople(groupPeopleID); List <Asset> assets = repositoryAsset.GetAllAssetsOfAssetOwner(assetOwner.AssetOwnerID); return(new Tuple <long, GroupPeople, List <PersonGroupPeople>, List <Asset> >(groupPeopleID, groupPeople, personGroupPeoples, assets)); }
public async Task <IActionResult> GroupaddRequest(int groupid) { if (ModelState.IsValid) { GroupPeople groupPeople = new GroupPeople() { UserId = User.FindFirstValue(ClaimTypes.NameIdentifier), GroupId = groupid, Status = 6 }; _context.Add(groupPeople); await _context.SaveChangesAsync(); return(RedirectToAction("GroupAbout", "GroupManagement", new { id = groupid, Messege = "Your request is sent. You will be a member after accepted by admin." })); } return(View()); }
// GET: GroupPeople/Details/ public IActionResult Details(long?id) { if (id == null) { return(NotFound()); } GroupPeople groupPeople = service.FindById(id.Value); if (groupPeople == null) { return(NotFound()); } ViewData["PersonID"] = new List <SelectListItem>(service.GetSelectListPeople()); return(View(groupPeople)); }
public async Task <IActionResult> CreateGroup([Bind("Id,Name,Objective,TermsCondition,MenbersType,CoverImage")] Group groupc) { if (ModelState.IsValid) { groupc.CreateTime = DateTime.Now; _context.Add(groupc); await _context.SaveChangesAsync(); GroupPeople groupPeople = new GroupPeople() { UserId = User.FindFirstValue(ClaimTypes.NameIdentifier), GroupId = groupc.Id, Status = 0 }; _context.Add(groupPeople); await _context.SaveChangesAsync(); return(RedirectToAction("GroupAbout", new { id = groupc.Id, Messege = "Your group is created" })); } return(View(groupc)); }
public async Task <IActionResult> GroupSetAdmin(string userId, int groupid) { if (GroupStatus(groupid) == 0) { if (ModelState.IsValid) { GroupPeople groupPeople = new GroupPeople() { UserId = userId, GroupId = groupid, Status = 4 }; _context.Add(groupPeople); await _context.SaveChangesAsync(); return(RedirectToAction("GroupAddAdmin", new { id = groupid, Messege = "Admin request is Sent" })); } return(View()); } else { return(NotFound()); } }
public async Task <IActionResult> GroupSetMember(string userId, int groupid) { if (GroupStatus(groupid) == 0 || GroupStatus(groupid) == 1) { if (ModelState.IsValid) { GroupPeople groupPeople = new GroupPeople() { UserId = userId, GroupId = groupid, Status = 5 }; _context.Add(groupPeople); await _context.SaveChangesAsync(); return(RedirectToAction("GroupAddMember", new { id = groupid })); } return(View()); } else { return(NotFound()); } }
public void Update(GroupPeople groupPeople) { context.GroupsPeople.Update(groupPeople); context.SaveChanges(); }
public void Add(GroupPeople groupPeople) { context.GroupsPeople.Add(groupPeople); context.SaveChanges(); }
public void Setup() { _sut = new GroupPeople(); _stopwatch = new Stopwatch(); }
public void Update(GroupPeople groupPeople) { repository.Update(groupPeople); }