コード例 #1
0
ファイル: AdminController.cs プロジェクト: HazzeDotCom/lunch
        public JsonResult GetData(AdminModel model)
        {
            switch (model.Tab.ToLower())
            {
                case "tabrestaurants":
                    var lunchareas = service.GetLunchAreas();
                    model.LunchAreaId = lunchareas.First().Id;
                    model.SelectlistItemsLunchAreas = lunchareas.Select(c => new SelectListItem() { Text = c.Name, Value = c.Id.ToString(), Selected = c.Id == model.LunchAreaId });

                    model.Restaurants = service.GetRestaurantsByLunchAreaId(model.LunchAreaId);
                    return Json(new { Partial = RenderPartialViewToString("RestaurantsPartial", model.Restaurants) });
                case "tablunchareas":
                    model.LunchAreas = service.GetLunchAreas();
                    return Json(new { Partial = RenderPartialViewToString("LunchAreasPartial", model.LunchAreas) });
                case "tabcompanies":
                    lunchareas = service.GetLunchAreas();
                    model.LunchAreaId = lunchareas.First().Id;
                    model.SelectlistItemsLunchAreas = lunchareas.Select(c => new SelectListItem() { Text = c.Name, Value = c.Id.ToString(), Selected = c.Id == model.LunchAreaId });
                    model.Companies = service.GetCompaniesByLunchArea(model.LunchAreaId);
                    return Json(new { Partial = RenderPartialViewToString("CompaniesPartial", model) });
                case "tblcompanies":
                    model.Companies = model.LunchAreaId > 0 ? service.GetCompaniesByLunchArea(model.LunchAreaId) : service.GetCompanies();
                   // model.CompanyCreateModel = new CompanyCreateModel();
                    return Json(new { Partial = RenderPartialViewToString("TblCompaniesPartial", model) });
                default:
                    model.LunchAreas = service.GetLunchAreas();
                    return Json(new { Partial = RenderPartialViewToString("LunchAreasPartial", model.LunchAreas) });
            }
        }
コード例 #2
0
ファイル: AdminController.cs プロジェクト: HazzeDotCom/lunch
        public ActionResult Index()
        {
            ViewBag.ActiveTab = 1;
            var model = new AdminModel();
            var lunchareas = service.GetLunchAreas();
            model.LunchAreaId = lunchareas.First().Id;
            //model.SelectlistItemsLunchAreas =
            //    lunchareas.Select(c => new SelectListItem() { Text = c.Name, Value = c.Id.ToString(), Selected = c.Id == model.LunchAreaId });

            return View(model);
        }