public IActionResult CreateOrchid([FromBody] OrchidNew newobj) //Create New Orchid { if (!ModelState.IsValid) { return(BadRequest()); } if (newobj == null) { return(BadRequest()); } _orchidnewRepo.CreateOrchid(newobj); return(NoContent()); }
[HttpPut("{id}")] //Update Method public IActionResult UpdateOrchid(int ID, [FromBody] OrchidNew newobj) { if (ID < 0) { return(BadRequest()); } int result = _orchidnewRepo.UpdateOrchid(ID, newobj); if (result == 0) { return(BadRequest()); } else { return(Ok()); } }
public int UpdateOrchid(int ID, OrchidNew orchidObject) { var orchids = _myDbContext.OrchidNews.Where(c => c.orchidID == ID).SingleOrDefault(); if (orchids == null) { return(0); } else { orchids.orchidName = orchidObject.orchidName; orchids.category = orchidObject.category; orchids.size = orchidObject.size; orchids.price = orchidObject.price; orchids.quanity = orchidObject.quanity; orchids.manuDate = orchidObject.manuDate; orchids.expTime = orchidObject.expTime; _myDbContext.SaveChanges(); return(1); //If Success Return One. } }
public void CreateOrchid(OrchidNew orchidObject) //enter a new data packet { _myDbContext.OrchidNews.Add(orchidObject); _myDbContext.SaveChanges(); }