protected override async Task ExecuteAsync(CancellationToken stoppingToken) { GroupCreateDTO groupCreate = new GroupCreateDTO(); groupCreate.ObjectGuid = Guid.NewGuid().ToString().Replace("-", ""); groupCreate.SamAccountName = "Group SamAccountName 11111"; groupCreate.DisplayName = "Group DisplayName 1212121212"; groupCreate.Name = "Group Name 12121212"; groupCreate.Description = "Group Description 12121212"; groupCreate.DistinguishedName = "Group DistinguishedName asakdalk"; groupCreate.GroupScope = GroupScopeEnum.DOMAIN.ToString(); groupCreate.GroupType = GroupTypeEnum.DISTRIBUTION.ToString(); groupCreate.LastAdChangeMillis = DateTimeOffset.Now.ToUnixTimeMilliseconds(); SyncEventDTO body = new SyncEventDTO(); body.ActiveDirectoryId = "5c11b84a4e9b467d84356761448a997e"; body.Type = "GROUP_CREATE"; body.Message = groupCreate; Console.WriteLine("ExecuteAsync ... "); BrokerHeader header = new BrokerHeader(); header.Tenant = "12345"; header.User = "******"; BrokerMessage message = new BrokerMessage(header, body); await _notifierService.Notify(message); }
public async Task <GroupDTO> PutAsync(GroupCreateDTO group) { this.Logger.LogTrace($"{nameof(this.PutAsync)} called"); var result = await this.GroupCreateService.CreateAsync(this.Mapper.Map <GroupUpdateModel>(group)); return(this.Mapper.Map <GroupDTO>(result)); }
public async Task <ActionResult <GroupDTO> > CreateAsync([FromBody] GroupCreateDTO model) { try { return(Ok(await groupService.CreateAsync(model))); } catch (NotFoundException e) { return(NotFound(new { e.Key, e.Message })); } catch (ValidationException e) { return(BadRequest(e.ValidationErrors)); } }
public async Task <ActionResult> CreateGroup([FromQuery] int?eventId, [FromQuery] int?groupParentId, [FromBody] GroupCreateDTO group) { // WARNING: Must set almost one id if (eventId == null && groupParentId == null) { return(BadRequest(new { error = "Must specify event id or a group parent id to make the connection" })); } Group _group = _mapper.Map <Group>(group); if (eventId != null) { var _event = await _context.Events.FindAsync(eventId); if (_event != null) { return(BadRequest(new { error = $"The event with id: {eventId} don't exists" })); } _event.Groups.Add(_group); } if (groupParentId != null) { var _groupParent = await _context.Groups.FindAsync(groupParentId); if (_groupParent != null) { return(BadRequest(new { error = $"The group with id: {groupParentId} don't exists" })); } _groupParent.ChildGroups.Add(_group); } await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(CreateGroup), new { id = _group.Id })); }
public IHttpActionResult CreateGroup(GroupCreateDTO dto) { var service = GetGroupService(); var rao = new GroupCreateRAO { GroupName = dto.GroupName }; if (service.CreateGroup(rao)) { return(Ok()); } else { return(BadRequest()); } }
public ActionResult Create(GroupCreateDTO dto) { if (!ModelState.IsValid) { return(View(dto)); } var svc = GetGroupService(); var rao = new GroupCreateRAO { GroupName = dto.GroupName }; if (svc.CreateGroup(rao)) { var id = svc.GetGroupIDByName(rao.GroupName); return(RedirectToAction("Index", new { id })); } TempData["FailResult"] = "Cannot create group."; return(View()); }