示例#1
0
        public async Task <ActionResult> CreateAsync([FromBody] NodeTypeViewModel model)
        {
            NodeType Entry = await service.GetByMachineNameAsync(model.MachineName);

            if (Entry != null)
            {
                return(BadRequest());
            }

            NodeType Request = mapper.Map <NodeTypeViewModel, NodeType>(model);

            return(Ok(await service.CreateAsync(Request)));
        }
示例#2
0
        public async Task <ActionResult <NodeTypeEntity> > CreateAsync([FromBody] NodeTypeCreateViewModel model)
        {
            NodeTypeEntity Entry = await service.GetByMachineNameAsync(model.MachineName);

            if (Entry != null)
            {
                return(BadRequest());
            }

            NodeTypeEntity Request = mapper.Map <NodeTypeCreateViewModel, NodeTypeEntity>(model);

            await service.CreateAsync(Request);

            return(CreatedAtRoute("GetByIdAsync", new { id = Request.Id }, new { id = Request.Id, name = Request.Name }));
        }