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

            var viewModel = new ColourDescModel { Active = true };

            return View(viewModel);
        }
예제 #2
0
        public virtual ActionResult Create(ColourDescModel viewModel)
        {
            ValidateIsAdmin();

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

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

            return RedirectToAction(MVC.Admin.ColourDesc.Index());
        }
예제 #3
0
        public virtual ActionResult Edit(ColourDescModel viewModel)
        {
            ValidateIsAdmin();

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

                record.Name = viewModel.Name;
                record.Active = viewModel.Active;
                record.ColourID = viewModel.ColourID;

                context.SaveChanges();
            }

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

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

                var viewModel = new ColourDescModel
                {
                    Active = record.Active,
                    ID = record.ID,
                    Name = record.Name,
                    ColourID = record.ColourID
                };

                return View(viewModel);
            }

        }