public async Task <IActionResult> EditType(int id, TypeCreateDto type) { var editType = new Type { Id = id, Name = type.Name, AvailableSubmit = type.AvailableSubmit, PointPerSubmit = type.PointPerSubmit, HasDashboardAccess = type.HasDashboardAccess, }; _context.Entry(editType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await TypeExists(id)) { return(NotFound()); } throw; } return(NoContent()); }
public async Task <ActionResult <Type> > CreateType(TypeCreateDto type) { var newType = new Type { Name = type.Name, AvailableSubmit = type.AvailableSubmit, PointPerSubmit = type.PointPerSubmit, HasDashboardAccess = type.HasDashboardAccess, }; _context.Type.Add(newType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTypeById", new { newType.Id }, newType)); }