public async Task <ExtraAttibruteType> addExtraAttibruteType(ExtraAttibruteType extraAttibruteType) { extraAttibruteType.extraAttibruteTypeId = 0; await _context.AddAsync(extraAttibruteType); await _context.SaveChangesAsync(); return(extraAttibruteType); }
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)); }
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)); }
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); }