示例#1
0
        public async Task <GenericResponse <UserTokenDto> > Get(long id)
        {
            UserTokenBo bo = null;
            ServiceResult <UserTokenBo> result = await serviceManager.UserToken_Service.GetByIdAsync(id);

            if (result.Success)
            {
                bo = result.Data;
            }
            else
            {
                Log(result.Error, LogLevel.Error, this.ControllerContext.RouteData.Values);
            }

            if (bo == null)
            {
                return(GenericResponse <UserTokenDto> .Error(ResultType.Error, "User Not Found!", "RT_G_01", StatusCodes.Status404NotFound));
            }

            return(GenericResponse <UserTokenDto> .Ok(UserTokenBo.ConvertToDto(bo)));
        }
示例#2
0
        public async Task <GenericResponse <UserTokenDto> > Post([FromBody] UserTokenDto dto)
        {
            UserTokenBo bo = UserTokenBo.ConvertToBusinessObject(dto);
            ServiceResult <UserTokenBo> result = await serviceManager.UserToken_Service.CreateAsync(bo);

            if (result.Success)
            {
                bo = result.Data;

                await serviceManager.CommitAsync();
            }
            else
            {
                return(GenericResponse <UserTokenDto> .Error(ResultType.Error, result.Error, "RT_PST_01", StatusCodes.Status500InternalServerError));
            }

            if (bo == null)
            {
                return(GenericResponse <UserTokenDto> .Error(ResultType.Error, "NOt Found!", "RT_PST_02", StatusCodes.Status404NotFound));
            }

            return(GenericResponse <UserTokenDto> .Ok(UserTokenBo.ConvertToDto(bo)));
        }