示例#1
0
        public async Task <ExtraAttibruteType> addExtraAttibruteType(ExtraAttibruteType extraAttibruteType)
        {
            extraAttibruteType.extraAttibruteTypeId = 0;
            await _context.AddAsync(extraAttibruteType);

            await _context.SaveChangesAsync();

            return(extraAttibruteType);
        }
示例#2
0
        public async Task <IActionResult> Post([FromBody] ExtraAttibruteType extraAttributeType)
        {
            if (ModelState.IsValid)
            {
                extraAttributeType = await _extraAttributeTypeService.addExtraAttibruteType(extraAttributeType);

                return(Created($"api/products/{extraAttributeType.extraAttibruteTypeId}", extraAttributeType));
            }
            return(BadRequest(ModelState));
        }
示例#3
0
        public async Task <IActionResult> Put(int id, [FromBody] ExtraAttibruteType extraAttributeType)
        {
            if (ModelState.IsValid)
            {
                extraAttributeType = await _extraAttributeTypeService.updateExtraAttibruteType(id, extraAttributeType);

                if (extraAttributeType == null)
                {
                    return(NotFound());
                }
                return(NoContent());
            }
            return(BadRequest(ModelState));
        }
示例#4
0
        public async Task <ExtraAttibruteType> updateExtraAttibruteType(int extraAttibruteTypeId, ExtraAttibruteType extraAttibruteType)
        {
            var curExtraAttibruteType = await _context.ExtraAttibruteTypes
                                        .Where(x => x.extraAttibruteTypeId == extraAttibruteTypeId)
                                        .FirstOrDefaultAsync();

            if (extraAttibruteType != null)
            {
                curExtraAttibruteType.extraAttibruteTypeName = extraAttibruteType.extraAttibruteTypeName;
                _context.ExtraAttibruteTypes.Update(curExtraAttibruteType);
                _context.Entry(curExtraAttibruteType).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(extraAttibruteType);
            }
            return(null);
        }