public bool CreateType(TypeCreate model)
        {
            Type entity = new Type
            {
                TypeName = model.TypeName
            };

            _context.Type.Add(entity);
            return(_context.SaveChanges() == 1);
        }
예제 #2
0
        public async Task <IActionResult> PostAsync([FromBody, Required] TypeCreate type)
        {
            if (!_user.HasPermission(Permissions.CREATE_SYMBOL_TYPE))
            {
                throw new Shared.Exceptions.InsuficientPermission()
                      {
                          ResourceName      = type.Name,
                          ResourceId        = type.Name,
                          ResourceType      = typeof(Data.Models.Symbols.Type),
                          MissingPermission = Permissions.CREATE_SYMBOL_TYPE
                      }
            }
            ;
            var mdl = await _symmgr.TypeManager.PostAsync(type.CreateModel());

            return(Json(Models.Output.Symbols.Type.CreateModel(mdl)));
        }
        public ActionResult Create(TypeCreate model)
        {
            if (ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateTypeService();

            if (service.CreateType(model))
            {
                TempData["SaveResult"] = "Your Type was added.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "The Type could not be added.");

            return(View(model));
        }
예제 #4
0
        private void createToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TypeCreate type = new TypeCreate();

            type.ShowDialog();
        }