コード例 #1
0
        //[Route("{entity}")]
        public async Task <IActionResult> PostOneAsync([FromBody] Component entity)
        {
            if (entity == null)
            {
                return(BadRequest());
            }

            // no duplicate imte allowed
            var result = await _entityRepository.GetOneAsyncByDescription(entity.imte);

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

            await _entityRepository.AddOneAsync(entity);

            return(CreatedAtRoute("GetComponent", new { controller = "Component", id = entity.Id }, entity));

            /* See http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2
             * // Validate and add book to database (not shown)
             *
             * var response = Request.CreateResponse(HttpStatusCode.Created);
             *
             * // Generate a link to the new book and set the Location header in the response.
             * string uri = Url.Link("GetBookById", new { id = book.BookId });
             * response.Headers.Location = new Uri(uri);
             * return response;
             */
        }
コード例 #2
0
        public async Task <IActionResult> AddOneAsync([FromBody] EquipmentActivity entity)
        {
            if (entity == null)
            {
                return(BadRequest());
            }

            var result = await _entityRepository.AddOneAsync(entity);

            //return CreatedAtRoute("GetEquipmentActivity", new { controller = "EquipmentActivity", id = entity.Id }, entity);
            return(Ok());
        }
コード例 #3
0
        public async Task <IActionResult> AddOneAsync([FromBody] Event entity)
        {
            if (entity == null)
            {
                return(BadRequest());
            }

            await _entityRepository.AddOneAsync(entity);

            //return true;
            return(CreatedAtRoute("GetEvent", new { controller = "Event", id = entity.Id }, entity));
        }
コード例 #4
0
        public async Task <IActionResult> AddOneAsync([FromBody] SystemTab entity)
        {
            if (entity == null)
            {
                return(BadRequest());
            }

            // no duplicate imte allowed
            var result = await _entityRepository.GetOneAsyncByDescription(entity.imte);

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

            await _entityRepository.AddOneAsync(entity);

            return(CreatedAtRoute("GetSystemTab", new { controller = "SystemTab", id = entity.Id }, entity));
        }