public ActionResult <string> Get(int id) { try { _medicamento = new Business.Medicamento.Medicamento(); string json = JsonConvert.SerializeObject(_medicamento.Get(id)); return(Ok(json)); } catch (Exception ex) { throw ex; } finally { _medicamento = null; } }
public ActionResult <string> Get(string nomeMedicamento) { try { _medicamento = new Business.Medicamento.Medicamento(); var a = _medicamento.Get(nomeMedicamento).Count(c => c == true); string json = JsonConvert.SerializeObject(a > 0 ? true : false); return(Ok(json)); } catch (Exception ex) { throw ex; } finally { _medicamento = null; } }
public ActionResult <IEnumerable <string> > Put(int id, [FromBody] Model.Model.Medicamento medicamento) { try { if (id == 0) { return(BadRequest("ENTER WITH A VALID ID.")); } _medicamento = new Business.Medicamento.Medicamento(); string json = JsonConvert.SerializeObject(_medicamento.Alter(id, medicamento)); return(Ok("DATA CHANGED SUCCESSFUL")); } catch (Exception ex) { throw ex; } finally { _medicamento = null; } }
public ActionResult <HttpContext> Post([FromBody] Model.Model.Medicamento medicamento) { try { if (medicamento == null || string.IsNullOrEmpty(medicamento.nomeMedicamento)) { return(BadRequest("ENTER WITH A VALID MEDICAMENTO.")); } _medicamento = new Business.Medicamento.Medicamento(); string json = JsonConvert.SerializeObject(_medicamento.Save(medicamento)); return(Ok("DATA INSERT SUCCESSFUL")); } catch (Exception ex) { throw ex; } finally { _medicamento = null; } }