public IActionResult Update(int id, [FromBody] GroupMemberViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != viewModel.Id) { return(BadRequest()); } try { var orginalGroupMember = _groupMemberService.Find(id); if (orginalGroupMember == null) { return(NotFound()); } orginalGroupMember = _mapper.Map(viewModel, orginalGroupMember); _groupMemberService.Update(orginalGroupMember); _unitOfWork.Commit(); return(NoContent()); } catch { return(StatusCode(500)); } }
public ExecutionResult Execute() { var groups = _groupService.GetAll(); foreach (var group in groups) { var creator = _groupMemberService.GetGroupMemberByMemberIdAndGroupId(group.CreatorId, group.Id); if (creator == null) { continue; } if (creator.IsAdmin) { continue; } creator.IsAdmin = true; _groupMemberService.Update(creator); } return(ExecutionResult.Success); }