Exemple #1
0
        public virtual ActionResult Create()
        {
            ValidateIsAdmin();

            var viewModel = new BrandModel { Active = true };

            return View(viewModel);
        }
Exemple #2
0
        public virtual ActionResult Create(BrandModel viewModel)
        {
            ValidateIsAdmin();

            using (var context = new TTTEntities())
            {
                var newRecord = new refbrand
                {
                    Active = viewModel.Active,
                    Name = viewModel.Name,
                    CreateDT = DateTime.Now,
                    CategoryID = viewModel.CategoryID
                };

                context.refbrands.Add(newRecord);
                context.SaveChanges();
            }

            return RedirectToAction(MVC.Admin.Brand.Index());
        }
Exemple #3
0
        public virtual ActionResult Edit(BrandModel viewModel)
        {
            ValidateIsAdmin();

            using (var context = new TTTEntities())
            {
                var record = context.refbrands.Single(a => a.ID == viewModel.ID);

                record.Name = viewModel.Name;
                record.Active = viewModel.Active;
                record.CategoryID = viewModel.CategoryID;

                context.SaveChanges();
            }

            return RedirectToAction(MVC.Admin.Brand.Index());
        }
Exemple #4
0
        public virtual ActionResult Edit(int id)
        {
            ValidateIsAdmin();

            using (var context = new TTTEntities())
            {
                var record = context.refbrands.Single(a => a.ID == id);

                var viewModel = new BrandModel
                {
                    Active = record.Active,
                    ID = record.ID,
                    Name = record.Name,
                    CategoryID = record.CategoryID
                };

                return View(viewModel);
            }

        }