コード例 #1
0
        public ActionResult Create(CarModelFormStub model)
        {
            //bool isNameExist = RepoCarModel.Find().Where(p => p.name == model.Name).Count() > 0;

            if (ModelState.IsValid)
            {
                car_model dbItem = new car_model();
                dbItem = model.GetDbObject(dbItem);

                try
                {
                    RepoCarModel.Save(dbItem);
                }
                catch (Exception e)
                {
                    model.FillCarBrandOptions(RepoCarBrand.FindAll());
                    return(View("Form", model));
                }

                //message
                string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString();
                this.SetMessage(model.Name, template);

                return(RedirectToAction("Index"));
            }
            else
            {
                model.FillCarBrandOptions(RepoCarBrand.FindAll());
                return(View("Form", model));
            }
        }
コード例 #2
0
        public ActionResult Create()
        {
            List <Business.Entities.car_brand> listCarBrand = RepoCarBrand.FindAll();

            CarModelFormStub formStub = new CarModelFormStub(listCarBrand);

            return(View("Form", formStub));
        }
コード例 #3
0
        public ActionResult Index()
        {
            var model = new CarModelFormStub();

            model.FillCarBrandOptions(RepoCarBrand.FindAll());
            ViewBag.ListBrand = new JavaScriptSerializer().Serialize(model.CarBrandOptions);

            return(View());
        }
コード例 #4
0
        public ActionResult Edit(Guid id)
        {
            car_model car_model = RepoCarModel.FindByPk(id);
            List <Business.Entities.car_brand> listCarBrand = RepoCarBrand.FindAll();
            CarModelFormStub formStub = new CarModelFormStub(car_model, listCarBrand);

            ViewBag.name = car_model.name;
            return(View("Form", formStub));
        }