public IActionResult Get(int page = 1, int size = 25, string order = "{}", string keyword = null, string filter = "{}")
        {
            try
            {
                Lib.Helpers.ReadResponse <InventoryDocument> read = Service.Read(page, size, order, keyword, filter);

                List <InventoryDocumentViewModel> listData = new List <InventoryDocumentViewModel>();
                foreach (var item in read.Data)
                {
                    listData.Add(Service.MapToViewModel(item));
                }
                return(Ok(new
                {
                    apiVersion = ApiVersion,
                    statusCode = General.OK_STATUS_CODE,
                    message = General.OK_MESSAGE,
                    data = listData,
                    info = new Dictionary <string, object>
                    {
                        { "count", listData.Count },
                        { "total", read.Count },
                        { "order", read.Order },
                        { "page", page },
                        { "size", size }
                    },
                }));
            }
            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));
            }
        }
Ejemplo n.º 2
0
        public IActionResult GetLoaderByUnitType(int page = 1, int size = 25, string order = "{}", [Bind(Prefix = "Select[]")] List <string> select = null, string keyword = null, string filter = "{}")
        {
            try
            {
                Lib.Helpers.ReadResponse <MachineSpinningModel> read = Service.ReadNoOnly(page, size, order, select, keyword, filter);

                List <MachineSpinningViewModel> dataVM = Mapper.Map <List <MachineSpinningViewModel> >(read.Data);

                dataVM = dataVM.Where(x => x.Types.Any(y => y.Type.Equals("Blowing", StringComparison.OrdinalIgnoreCase))).ToList();

                Dictionary <string, object> Result =
                    new Utils.ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE)
                    .Ok(Mapper, dataVM, page, size, read.Count, dataVM.Count, read.Order, read.Selected);
                return(Ok(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new Utils.ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }