Esempio n. 1
0
        public async Task <ActionResult> UpdateAsync(int id, [FromBody] NodeTypeViewModel model)
        {
            NodeTypeEntity Request = mapper.Map <NodeTypeViewModel, NodeTypeEntity>(model);

            if (id != model.Id)
            {
                return(BadRequest());
            }

            try
            {
                await service.UpdateAsync(Request);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!service.NodeTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
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)));
        }
Esempio n. 3
0
        public async Task <ActionResult <MenuShortViewModel> > GetByMachineNameAsync(string machineName)
        {
            NodeType Entry = await service.GetByMachineNameAsync(machineName);

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

            NodeTypeViewModel Response = mapper.Map <NodeType, NodeTypeViewModel>(Entry);

            return(Ok(Response));
        }
Esempio n. 4
0
        public async Task <ActionResult <NodeTypeViewModel> > GetByIdAsync(int id)
        {
            NodeType Entry = await service.GetByIdAsync(id);

            if (Entry == null)
            {
                return(NotFound());
            }

            NodeTypeViewModel Response = mapper.Map <NodeType, NodeTypeViewModel>(Entry);

            return(Ok(Response));
        }
Esempio n. 5
0
        public async Task <ActionResult> UpdateAsync(int id, [FromBody] NodeTypeViewModel model)
        {
            NodeType Entry = await service.GetByIdAsync(id);

            if (Entry == null)
            {
                return(NotFound());
            }

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

            await service.UpdateAsync(id, Request);

            return(NoContent());
        }