示例#1
0
        public async Task <TModelViewGet> Get(string code)
        {
            return(await Task.Run <TModelViewGet>(() =>
            {
                var request = new ManagementModelRetrieverRequest <TModel>
                {
                    Code = code
                };


                var result = _retrieverBusinessLogic.Execute(request);
                if (!result.ComputeResult().IsOk()
                    ||
                    request.Items?.Count() != 1)
                {
                    throw new System.Web.Http.HttpResponseException(HttpStatusCode.NotFound)
                    {
                        Source = result.Message()
                    };
                }

                var resultGot = _mapper.Map <TModelViewGet>(request.Items.ToList()[0]);
                return resultGot;
            }));
        }
        public ActionResult <IEnumerable <TModelViewGet> > Get()
        {
            var request = new ManagementModelRetrieverRequest <TModel> {
                User = CurrentUser
            };

            var result = _retrieverBusinessLogic.Execute(request);

            if (result.ComputeResult().IsOk())
            {
                return(Ok(_mapper.Map <IEnumerable <TModelViewGet> >(request.Items)));
            }

            return(BadRequest(result));
        }
示例#3
0
        public IEnumerable <TModelViewGet> Get()
        {
            var request = new ManagementModelRetrieverRequest <TModel> {
            };

            var result = _retrieverBusinessLogic.Execute(request);

            if (result.ComputeResult().IsOk())
            {
                return(_mapper.Map <IEnumerable <TModelViewGet> >(request.Items));
            }

            throw new System.Web.Http.HttpResponseException(HttpStatusCode.NotFound)
                  {
                      Source = result.Message()
                  };
        }
示例#4
0
        public async Task <IEnumerable <TModelViewGet> > Get()
        {
            //return await Task.FromException<IEnumerable<TModelViewGet>>(new Exception("result.Message()"));

            return(await Task <IEnumerable <TModelViewGet> > .Run(() =>
            {
                var request = new ManagementModelRetrieverRequest <TModel> {
                };

                var result = _retrieverBusinessLogic.Execute(request);
                if (!result.ComputeResult().IsOk())
                {
                    return Task.FromException <IEnumerable <TModelViewGet> >(new Exception(result.Message())).Result;
                }

                return _mapper.Map <IEnumerable <TModelViewGet> >(request.Items);
            }));
        }
        public ActionResult <TModelViewGet> Get(string code)
        {
            var request = new ManagementModelRetrieverRequest <TModel>
            {
                User = CurrentUser,
                Code = code
            };


            var result = _retrieverBusinessLogic.Execute(request);

            if (!result.ComputeResult().IsOk()
                ||
                request.Items?.Count() != 1)
            {
                return(NotFound(result));
            }

            return(_mapper.Map <TModelViewGet>(request.Items.FirstOrDefault()));
        }
示例#6
0
        public IEnumerable <TModelViewGet> Get(string code)
        {
            var request = new ManagementModelRetrieverRequest <TModel>
            {
                Code = code
            };


            var result = _retrieverBusinessLogic.Execute(request);

            if (!result.ComputeResult().IsOk())
            {
                throw new System.Web.Http.HttpResponseException(HttpStatusCode.NotFound)
                      {
                          Source = result.Message()
                      };
            }

            return(_mapper.Map <IEnumerable <TModelViewGet> >(request.Items.ToList()));
            //var res = _service.Get(code);
            //return _mapper.Map<IEnumerable<TModelViewGet>>(res);;
        }