public IHttpActionResult PutPetUpdateMaster(PetUpdate petupdate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { PetUpdate objEmp = new PetUpdate(); objEmp = objEntity.PetUpdates.Find(petupdate.PetUpdateID); if (objEmp != null) { objEmp.UpdateDate = petupdate.UpdateDate; objEmp.NameDescription = petupdate.NameDescription; objEmp.FeedingStatus = petupdate.FeedingStatus; objEmp.WalkingStatus = petupdate.WalkingStatus; objEmp.GroomedStatus = petupdate.GroomedStatus; } int i = this.objEntity.SaveChanges(); } catch (Exception) { throw; } return(Ok(petupdate)); }
public ActionResult Update(int id) { Pet selectedpet = db.Pets.SqlQuery("select * from pets where petid = @id", new SqlParameter("@id", id)).FirstOrDefault(); List <Species> species = db.Species.SqlQuery("select * from Species").ToList(); PetUpdate petUpdate = new PetUpdate(); petUpdate.Pet = selectedpet; petUpdate.Species = species; return(View(petUpdate)); }
public IHttpActionResult PostPetUpdate(PetUpdate data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { objEntity.PetUpdates.Add(data); objEntity.SaveChanges(); } catch (Exception) { throw; } return(Ok(data)); }
public IHttpActionResult GetPetUpdateById(string petupdateId) { PetUpdate objEmp = new PetUpdate(); objEntity.Configuration.ProxyCreationEnabled = false; int ID = Convert.ToInt32(petupdateId); try { objEmp = objEntity.PetUpdates.Find(ID); if (objEmp == null) { return(NotFound()); } } catch (Exception) { throw; } return(Ok(objEmp)); }