Esempio n. 1
0
        public ActionResult Save(BrandEditorModel model, string @return)
        {
            Brand brand = null;

            if (model.Id > 0)
            {
                brand = _brandService.Find(model.Id);
            }
            else
            {
                brand = new Brand();
            }

            brand.Name = model.Name;
            brand.Description = model.Description;

            brand.CustomFields.Clear();

            foreach (var field in model.CustomFields)
            {
                brand.CustomFields.Add(new BrandCustomField(field.Name, field.Value));
            }

            if (model.Id > 0)
            {
                _brandService.Update(brand);
            }
            else
            {
                _brandService.Create(brand);
            }

            return AjaxForm().RedirectTo(@return);
        }
Esempio n. 2
0
        public ActionResult Save(BrandEditorModel model, string @return)
        {
            model.CustomFields = FormHelper.BindToModels<BrandCustomFieldModel>(Request.Form, "CustomFields.");
            Brand brand = new Brand();
            model.UpdateTo(brand);
            _brandService.Save(brand);

            return AjaxForm().RedirectTo(@return);
        }
Esempio n. 3
0
 public ActionResult Create()
 {
     var model = new BrandEditorModel();
     return View(model);
 }
Esempio n. 4
0
 public ActionResult Edit(int id)
 {
     var brand = _brandService.GetById(id);
     var model = new BrandEditorModel(brand);
     return View(model);
 }