public IHttpActionResult Put(UpdateMyPlantModel plant) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateMyPlantService(); if (!service.UpdateMyPlant(plant)) { return(InternalServerError()); } return(Ok()); }
//UpdateMyPlant method takes in myPlantID of the plant you would like to update and new infomation that needs to be updated. //Populates the new updated information using UpdateMyPlantModel public bool UpdateMyPlant(UpdateMyPlantModel model) { MyPlants myPlants = ctx.MyPlants.Single(e => e.MyPlantID == model.MyPlantID); if (myPlants.UserID != _userID) { return(false); } myPlants.Location = model.Location; myPlants.DatePlanted = model.DatePlanted; myPlants.Photo = model.Photo; myPlants.Notes = model.Notes; myPlants.Year = model.Year; myPlants.ModifiedDate = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); }