Ejemplo n.º 1
0
        public ActionResult Edit(CarBrandFormStub model)
        {
            //bool isNameExist = RepoKompetitor.Find().Where(p => p.name == model.Name && p.id != model.Id).Count() > 0;

            if (ModelState.IsValid)
            {
                car_brand dbItem = RepoCarBrand.FindByPk(model.Id);
                dbItem = model.GetDbObject(dbItem);

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

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

                return(RedirectToAction("Index"));
            }
            else
            {
                car_brand car_brand = RepoCarBrand.FindByPk(model.Id);
                ViewBag.name = car_brand.name;
                return(View("Form", model));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(System.Guid id)
        {
            car_brand car_brand = RepoCarBrand.FindByPk(id);

            ViewBag.name = car_brand.name;
            CarBrandFormStub formStub = new CarBrandFormStub(car_brand);

            return(View("Form", formStub));
        }
Ejemplo n.º 3
0
        public ActionResult Create(CarBrandFormStub model)
        {
            //bool isNameExist = RepoCarBrand.Find().Where(p => p.name == model.Name).Count() > 0;

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

                RepoCarBrand.Save(dbItem);


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

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View("Form", model));
            }
        }
Ejemplo n.º 4
0
        public ActionResult Create()
        {
            CarBrandFormStub formStub = new CarBrandFormStub();

            return(View("Form", formStub));
        }