Esempio n. 1
0
        public async Task <ActionResult> Query(EquipmentLayoutDetailQueryViewModel model)
        {
            using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
            {
                MethodReturnResult <EquipmentLayout> result = await client.GetAsync(model.LayoutName ?? string.Empty);

                ViewBag.EquipmentLayout = result.Data;
            }

            using (EquipmentLayoutDetailServiceClient client = new EquipmentLayoutDetailServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(" Key.LayoutName = '{0}'"
                                                 , model.LayoutName)
                    };
                    MethodReturnResult <IList <EquipmentLayoutDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            using (EquipmentStateServiceClient client = new EquipmentStateServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false
                    };
                    MethodReturnResult <IList <EquipmentState> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.StateList = result.Data;
                    }
                });
            }
            return(PartialView("_ListPartial", new EquipmentLayoutDetailViewModel()
            {
                LayoutName = model.LayoutName
            }));
        }
        //
        // GET: /FMM/EquipmentLayoutDetail/
        public async Task <ActionResult> Index(string layoutName)
        {
            using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
            {
                MethodReturnResult <EquipmentLayout> result = await client.GetAsync(layoutName ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "EquipmentLayout"));
                }
                ViewBag.EquipmentLayout = result.Data;
            }

            using (EquipmentLayoutDetailServiceClient client = new EquipmentLayoutDetailServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(" Key.LayoutName = '{0}'"
                                                 , layoutName)
                    };
                    MethodReturnResult <IList <EquipmentLayoutDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", new EquipmentLayoutDetailViewModel()
                {
                    LayoutName = layoutName
                }));
            }
            else
            {
                return(View(new EquipmentLayoutDetailQueryViewModel()
                {
                    LayoutName = layoutName
                }));
            }
        }