private static void DisplayGroup(GroupDto group) { Output.InWhite.WriteLine(); Output.InYellow.WriteLine("[{1,3}] {0}", group.Name, group.Id); Output.InWhite.WriteLine("----------------------------"); Output.InDarkYellow.WriteLine("Beneficiaries:"); foreach (var b in group.People) { Output.InWhite.WriteLine("\t[{0}] {1} {2}", b.IsEducator ? "EDUCATOR" : "BENEFICIARY", b.Name, b.Surname); } }
public async Task<IHttpActionResult> CreateGroup([FromBody]GroupDto group) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var userId = User.Identity.GetUserId(); group.OwnerUserId = userId; var result = await _groupService.AddAsync(group); await _userGroupService.AddAsync(userId, result.GroupId); return Created(Url.Request.RequestUri + "/" + result.GroupId, result); }
public async Task <GroupDto> UpdateAsync(int id, GroupDto dto) { dto.BossCharacter = null; dto.DefaultRank = null; GroupModel model = await _unitOfWork.GroupsRepository.JoinAndGetAsync(id); _mapper.Map(dto, model); await _unitOfWork.SaveAsync(); return(dto); }
public async Task <GroupDto> Get(int id) { var entity = await this._unitOfWork.Group.Get(id); if (!entity.IsVisible) { return(null); } GroupDto groupDto = _mapper.Map <GroupDto>(entity); return(groupDto); }
public async Task <int> Post(GroupDto group) { var id = await _groupService.InsertAsync(new GroupDto { IsActive = group.IsActive, Name = group.Name, Description = group.Description, }); return(id); }
public void Update(GroupDto @group) { if (group == null) { throw new ArgumentNullException("Value is a null"); } var groupEntity = Mapper.Map <Group>(group); _dbContext.Groups.Update(groupEntity); _dbContext.SaveChanges(); }
public async Task <ActionResult <Group> > RegisterGroup(GroupDto newGroup) { var group = new Group { Id = newGroup.Id, Name = newGroup.Name }; _dataContext.Groups.Add(group); await _dataContext.SaveChangesAsync(); return(group); }
private Group GetGroup(GroupDto groupDto) { return(new Group { Id = groupDto.Id ?? 0, GroupName = groupDto.GroupName, Description = groupDto.Description, Email = groupDto.Email, EnabledEmail = groupDto.EnabledEmail, ParentGroupId = groupDto.ParentGroupId }); }
public async Task <GroupDto> AddAsync(GroupDto groupDto) { var group = _mapper.Map <GroupDto, Group>(groupDto); var result = await _groupRepository.AddAsync(group); if (result.Status == RepositoryStatus.Created) { var entity = result.Entity; return(_mapper.Map <Group, GroupDto>(entity)); } throw new ServiceException(ErrorCodes.DatabaseError); }
private IList <Movie> GetMoviesGroup(GroupDto groupOne, GroupDto groupTwo) { return(new List <Movie> { _tiebreaker.Apply(new List <Movie> { groupOne.Movies.First(), groupTwo.Movies.Last() }).First(), _tiebreaker.Apply(new List <Movie> { groupTwo.Movies.First(), groupOne.Movies.Last() }).First() }); }
public int AddGroup(GroupDto value) { if (ModelState.IsValid) { using (KivoDbContext context = new KivoDbContext(Configuration.GetConnectionString("DefaultConnection"))) { return(context.Group.Add(value.ConvertToGroup())); } } return(0); }
public void Execute(GroupDto request) { _validator.ValidateAndThrow(request); var group = new Group { Name = request.Name }; _context.Groups.Add(group); _context.SaveChanges(); }
public GroupDto GetSingle(Guid id) { GroupDto groupDto = null; using (ISession session = _sessionFactory.OpenSession()) { IRepository <Group> groupRepository = new Repository <Group>(session); var group = groupRepository.FindOne(id); groupDto = Mapper.Map <GroupDto>(group); } return(groupDto); }
public void GroupDtoValidation_Valid_NoErrors() { var dto = new GroupDto { Name = RandomFactory.GetCompanyName(), }; var validationContext = new ValidationContext(dto); var validationResults = dto.Validate(validationContext); validationResults.Should().HaveCount(0); }
private Group MapGroupDto(GroupDto groupDto) { Group group = _mapper.Map <Group>(groupDto); ClientProfile profile = _database.ClientProfileRepository.GetByName(groupDto.Username); if (profile != null) { group.ApplicationUserId = profile.Id; return(group); } return(null); }
public async Task <GroupDto> CreateGroup(GroupDto groupDto) { Group group = MapGroupDto(groupDto); if (group == null) { return(null); } group = await _database.GroupRepository.Create(group); return(await MapGroup(group)); }
public static GroupDto ToGroupDto(this Group group) { var groupDto = new GroupDto(); if (group != null) { groupDto.Id = group.Id; groupDto.Title = group.Title; groupDto.Created = group.Created; groupDto.Number = group.Number; } return(groupDto); }
public IActionResult CreateGroup(GroupDto groupDto) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var group = new Group { Name = groupDto.Name, UserId = userId }; _context.Add(group); _context.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public bool Save(GroupDto dto) { try { bool retVal = this.dal.Save(dto.Id, dto.Name); return(retVal); } catch (Exception ex) { base.Logger.Error("[GroupLogic] An error occurred", ex); throw; } }
public GroupDto GetByName(string name) { try { GroupDto retVal = this.dal.GetByName(name).ToDto(); return(retVal); } catch (Exception ex) { base.Logger.Error("[GroupLogic] An error occurred", ex); throw ex; } }
public IHttpActionResult GetGroup(int id) { var group = db.Groups.Find(id); if (group == null) { return(NotFound()); } var dto = new GroupDto(group); return(Ok(dto)); }
public async Task <IActionResult> Join([FromBody] GroupDto group) { var email = User.GetEmail(); var joined = await _userLogic.JoinGroup(group, email); if (joined) { return(Ok()); } return(NotFound()); }
public async Task <IActionResult> Put(string groupName, [FromBody] GroupDto group) { var existingGroup = await _groupsService.GetGroupAsync(groupName); if (existingGroup == null) { return(NotFound()); } await _groupsService.UpdateGroupAsync(groupName, group); return(Ok()); }
public async Task <int> AddGroupAsync(GroupDto groupDto) { if (groupDto == null) { throw new ArgumentNullException($"Argument {nameof(groupDto)} can't be null!"); } int id = context.Set <Group>().Add(groupDto.ToGroup()).Id; await context.SaveChangesAsync(); return(id); }
public async Task PutGroup(GroupDto group) { try { var response = await PutAsJsonAsync(client, "api/groups/" + group.ID, group); response.EnsureSuccessStatusCode(); } catch (Exception) { return; } }
public async Task CreateGroupCommand(GroupDto group) { try { var response = await PostAsJsonAsync(client, "api/groups", group); response.EnsureSuccessStatusCode(); } catch (Exception) { return; } }
public void Execute(GroupDto request) { _validator.ValidateAndThrow(request); var group = _context.Groups.Find(request.Id); if (group == null) { throw new EntityNotFoundException(request.Id, typeof(Group)); } _mapper.Map(request, group); _context.SaveChanges(); }
public ActionResult ShowGroupPage(int groupId) { int userId = ((UserDto)Session["session"]).Id; GroupDto groupDto = groupService.GetGroupDtoById(groupId, userId); ViewData["mainWallId"] = groupService.GetGroupMainWallId(groupId); GroupRoles role = groupService.GetUserRoleInGroup(userId, groupId); ViewData["role"] = role; ViewData["groupId"] = groupId; ViewData["requestIsSent"] = groupService.CheckRequest(userId, groupId); return(View("GroupPage", groupDto)); }
public static GroupDto ConvertGroupToGroupDto(Group group) { GroupDto groupDto = new GroupDto() { Id = group.Id, Name = group.Name, Members = group.UserGroups.Where(ug => !ug.IsAdmin).Select(ug => ug.UserId).ToList(), Administrators = group.UserGroups.Where(ug => ug.IsAdmin).Select(ug => ug.UserId).ToList(), Files = group.Files.Where(f => f.GroupId == group.Id).Select(f => f.Id).ToList() }; return(groupDto); }
public IActionResult Get(long id) { Group group = _groupService.GetById(id); if (group == null) { return NotFound(); } GroupDto groupToReturn = _mapper.Map<GroupDto>(group); return Ok(groupToReturn); }
public async Task <GroupDto> GetGroupById(int groupId) { var grp = await _context.Groups.FirstOrDefaultAsync(x => x.Id == groupId); var group = new GroupDto { UserId = 0, GroupId = grp.Id, GroupName = grp.GroupName }; return(group); }
public DResult AddGroup(GroupDto dto, string creatorId) { if (Groups.Exists(g => g.Code == dto.Code || g.Group == dto.Name)) return DResult.Error("词条分类已存在!"); var item = dto.MapTo<WikiGroup>(); item.Id = CombHelper.Guid16; item.CreateTime = Clock.Now; item.WikiCount = 0; item.CreatorId = creatorId; item.Sort = Groups.Max(g => g.Sort) + 1; var result = Groups.Insert(item); return string.IsNullOrWhiteSpace(result) ? DResult.Error("添加词条分类失败!") : DResult.Success; }
public ActionResult AddGroup(GroupDto dto) { var result = _wikiContract.AddGroup(dto, string.Empty); return DeyiJson(result); }