예제 #1
0
        public ActionResult Create(TagFormViewModel viewModel)
        {
            var tag = new Tag
            {
                Name      = viewModel.Tag.Name,
                TagTypeId = viewModel.Tag.TagTypeId,
                PlcId     = viewModel.Tag.PlcId,
                IsActive  = viewModel.Tag.IsActive
            };

            _context.Tags.Add(tag);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Tags"));
        }
예제 #2
0
        public ActionResult Create()
        {
            var types = _context.TagTypes.ToList();
            var plcs  = _context.Plcs.ToList();

            var viewModel = new TagFormViewModel
            {
                Tag      = new Tag(),
                TagTypes = types,
                Plcs     = plcs
            };

            if (User.IsInRole(RoleName.Administrator))
            {
                return(View("Create", viewModel));
            }

            return(View("Create", viewModel));
        }