public async Task <IActionResult> PutUserType(int id, UserType userType) { //Update a user type if (id != userType.UserTypeID) { return(BadRequest()); } _context.Entry(userType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutComments(int id, Comments comments) { //Update a comment based on its id if (id != comments.CommentID) { return(BadRequest()); } _context.Entry(comments).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutApprovedType(int id, ApprovedType approvedType) { //Update approved type based on the id and object provided if (id != approvedType.ApprovedTypeID) { return(BadRequest()); } _context.Entry(approvedType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ApprovedTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutArticle(int id, Article article) { //Update an article if (id != article.ArticleID) { return(BadRequest()); } _context.Entry(article).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArticleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEdible(int id, EdibleDto edible) { //Update an edible value, at the Id with the information provided var result = await _context.Edibles.SingleOrDefaultAsync(e => e.EdibleID == id); if (result != null) { result.EdibleS = edible.info; await _context.SaveChangesAsync(); return(Ok()); } return(NotFound()); }
public async Task <IActionResult> ApproveOrDisapprovePlant(int id, int approvalType) { //update the approval of a plant var result = await _context.Plants.SingleOrDefaultAsync(p => p.PlantID == id); if (result != null) { result.FK_ApprovedTypeID = approvalType; await _context.SaveChangesAsync(); return(Ok()); } return(NotFound()); }
public async Task <IActionResult> PutPlantType(int id, PlantTypeDto plantType) { //Update the plant type var result = await _context.PlantTypes.SingleOrDefaultAsync(t => t.PlantTypeID == id); if (result != null) { result.PType = plantType.info; await _context.SaveChangesAsync(); return(Ok()); } return(NotFound()); }
public async Task <IActionResult> PutClimates(int id, ClimatesDto climate) { //Update climate based on the id, and DTO provided var result = await _context.Climates.SingleOrDefaultAsync(c => c.ClimateID == id); if (result != null) { result.Climate = climate.info; await _context.SaveChangesAsync(); return(Ok()); } return(NotFound()); }
public async Task <IActionResult> PutUsers(int id, UsersDto user) { //Update a user at the ID var result = await _context.Users.SingleOrDefaultAsync(u => u.UserID == id); if (result != null) { result.Username = user.username; result.Password = user.password; await _context.SaveChangesAsync(); return(Ok()); } return(NotFound()); }