public ICommandResult Handle(GetGroupCommand command)
        {
            ICommandResult result = new GetGroupCommandResult();

            _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.Group, command.RequestHost }, "GroupCommandHandler.Handle(Get)");

            try
            {
                if (_groupRepository.CheckExists(command.Group))
                {
                    Group group = _groupRepository.Get(command.Group);

                    if (group != null)
                    {
                        result = new GetGroupCommandResult(200, group.Name, group.Description);
                    }
                }

                else if (_groupRepository.Valid)
                {
                    result = new GetGroupCommandResult(400, new Notification("Group", "Could not be found"));
                }
            }
            catch (Exception e)
            {
                _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.Group, command.RequestHost }, e);
            }

            return(result);
        }
Example #2
0
        public GetGroupCommandResult Get(Guid id)
        {
            GetGroupCommand command = new GetGroupCommand()
            {
                Group = id
            };

            command.setRequestHost(HttpContext.Request.Host.ToString());

            _loggingService.Log(this.GetType(), ELogType.Input, ELogLevel.Info, new { Group = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method });

            GetGroupCommandResult result = (GetGroupCommandResult)_groupHandler.Handle(command);

            _loggingService.Log(this.GetType(), ELogType.Output, ELogLevel.Info, new { Group = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method, Code = this.Response.StatusCode });

            HttpContext.Response.StatusCode = result.Code;

            return(result);
        }
        public async Task <ActionResult <GroupModel> > GetGroup(int uId, int gId)
        {
            var getGroupCommand = new GetGroupCommand(uId, gId);

            return(await _mediator.Send(getGroupCommand));
        }