public Models.TbListaFofa Salvar(Models.TbListaFofa ln) { db.Add(ln); db.SaveChanges(); return(ln); }
public Models.TbListaFofa ParaTabela(Models.Request.ListaFofaRequest request) { Models.TbListaFofa lf = new Models.TbListaFofa(); lf.NmFofura = request.Fofura; lf.DsPorque = request.Porque; lf.DtNiver = request.Niver; lf.BtColocariaPotinho = request.ColocariaPotinho; return(lf); }
public Models.Response.ListaFofaResponse ParaResponse(Models.TbListaFofa ln) { Models.Response.ListaFofaResponse resp = new Models.Response.ListaFofaResponse(); resp.Id = ln.IdListaFofa; resp.Nome = ln.NmFofura; resp.Porque = ln.DsPorque; resp.Niver = ln.DtNiver; resp.ColocariaPotinho = ln.BtColocariaPotinho; return(resp); }
public Models.TbListaFofa Deletar(int id) { Models.TbListaFofa ln = db.TbListaFofa.FirstOrDefault(x => x.IdListaFofa == id); if (ln != null) { db.TbListaFofa.Remove(ln); db.SaveChanges(); } return(ln); }
public Models.TbListaFofa Salvar(Models.TbListaFofa lf) { if (lf.NmFofura == string.Empty) { throw new Exception("Fofura é obrigatório."); } if (lf.DsPorque == string.Empty) { throw new Exception("Porque é obrigatório."); } return(db.Salvar(lf)); }
public Models.TbListaFofa Alterar(int id, Models.TbListaFofa novo) { if (novo.NmFofura == string.Empty) { throw new Exception("Nome é obrigatório"); } if (novo.DsPorque == string.Empty) { throw new Exception("Motivo é obrigatório"); } return(db.Alterar(id, novo)); }
public Models.TbListaFofa Salvar(Models.TbListaFofa ln) { if (ln.NmFofura == string.Empty) { throw new Exception("Nome é obrigatório"); } if (ln.DsPorque == string.Empty) { throw new Exception("Motivo é obrigatório"); } return(db.Salvar(ln)); }
public ActionResult <Models.Response.ListaFofaResponse> Deletar(int id) { try { Models.TbListaFofa ln = business.Deletar(id); Models.Response.ListaFofaResponse resp = conversor.ParaResponse(ln); return(resp); } catch (System.Exception ex) { return(BadRequest( new Models.Response.ErroResponse(404, ex.Message) )); } }
public Models.TbListaFofa Alterar(int id, Models.TbListaFofa novo) { Models.TbListaFofa ln = db.TbListaFofa.FirstOrDefault(x => x.IdListaFofa == id); if (ln != null) { ln.NmFofura = novo.NmFofura; ln.DsPorque = novo.DsPorque; ln.BtColocariaPotinho = novo.BtColocariaPotinho; ln.DtNiver = novo.DtNiver; db.SaveChanges(); } return(ln); }
public ActionResult <Models.Response.ListaFofaResponse> Alterar(int id, Models.Request.ListaFofaRequest request) { try { Models.TbListaFofa ln = conversor.ParaTabela(request); business.Alterar(id, ln); Models.Response.ListaFofaResponse resp = conversor.ParaResponse(ln); return(resp); } catch (System.Exception ex) { return(BadRequest( new Models.Response.ErroResponse(404, ex.Message) )); } }
public ActionResult <Models.Response.ListaFofaResponse> Inserir(Models.Request.ListaFofaRequest request) { try { Models.TbListaFofa lf = conversor.ParaTabela(request); business.Salvar(lf); Models.Response.ListaFofaResponse resp = conversor.ParaResponse(lf); return(resp); } catch (System.Exception ex) { return(BadRequest( new Models.Response.ErroResponse(404, ex.Message) )); } }