コード例 #1
0
        public async Task Should_Success_Get_All_Data()
        {
            ExpeditionFacade facade = new ExpeditionFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            var model = await dataUtil(facade, GetCurrentMethod()).GetTestData();

            var Response = facade.Read();

            Assert.NotEmpty(Response.Item1);
        }
コード例 #2
0
        public IActionResult Get(int page = 1, int size = 25, string order = "{}", string keyword = null, string filter = "{}")
        {
            try
            {
                identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

                var Data = facade.Read(page, size, order, keyword, filter);

                var viewModel = mapper.Map <List <ExpeditionViewModel> >(Data.Item1);

                List <object> listData = new List <object>();
                listData.AddRange(
                    viewModel.AsQueryable().Select(s => new {
                    s._id,
                    s.code,
                    s.expeditionService.name,
                    s.weight,
                    s.date,
                    destination = s.items.Select(i => i.spkDocsViewModel.destination.name),
                    s.CreatedBy
                })
                    );

                var info = new Dictionary <string, object>
                {
                    { "count", listData.Count },
                    { "total", Data.Item2 },
                    { "order", Data.Item3 },
                    { "page", page },
                    { "size", size }
                };

                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE)
                    .Ok(listData, info);
                return(Ok(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }