示例#1
0
        public void GetAlertTypes_Success()
        {
            IAlertsDal dal = PrepareAlertsDal();
            IAlertsDalGetAlertTypesParams getTypesParams = dal.CreateGetAlertTypesParams();

            var getTypesResult = dal.GetAlertTypes(getTypesParams);

            Assert.IsTrue(getTypesResult.Success);
            Assert.IsNotNull(getTypesResult.Types != null);
            Assert.IsNotEmpty(getTypesResult.Types);
        }
        public object Any(GetAlertsTypes request)
        {
            GetAlertsTypesResponse response = new GetAlertsTypesResponse();

            TransferHeader(request, response);

            try
            {
                IAlertsDalGetAlertTypesParams getParams = _dal.CreateGetAlertTypesParams();

                var getResult = _dal.GetAlertTypes(getParams);

                if (getResult.Success)
                {
                    foreach (var at in getResult.Types)
                    {
                        response.Payload.Types.Add(new DTO.AlertType()
                        {
                            ID   = at.ID,
                            Name = at.Name,
                            Desc = at.Desc
                        });
                    }

                    response.Success = true;
                }
                else
                {
                    response.Success = false;
                    response.Errors.AddRange(getResult.Errors);
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Errors.Add(new Interfaces.Error()
                {
                    Code    = Interfaces.EErrorCodes.GeneralError,
                    Type    = Interfaces.EErrorType.Error,
                    Message = ex.Message
                });
            }

            return(response);
        }