public Dictionary <string, object> ParseToParameters(MotivoN1 t) { Dictionary <string, object> d = new Dictionary <string, object>(); d.Add("ID", t.ID); d.Add("DESCRICAOMOTIVO", this.GetValueOrDbNull(t.Descricao)); d.Add("DATARI", this.GetValueOrDbNull(t.DataRI)); return(d); }
public MotivoN1 ParseToDTO(DataRow row) { MotivoN1 m = new MotivoN1(); m.ID = row.ParseToInt64("id"); m.Descricao = row.ParseToString("descMotivoN1"); m.DataRI = row.ParseToDatetime("dataRI"); try { m.MotivoN2 = new DAOFactory().InitMotivoN2DAO().GetByMotivoN1(m); } catch { } return(m); }
public IActionResult DeleteMotivoN1([FromServices] DAOFactory dao, [FromBody] MotivoN1 motivo) { if (motivo.ID <= 0) { return(this.WriteErrorInfo("Erro ao deletar MotivoN1, ID não pode ser nulo.")); } try { var result = dao.InitMotivoN1DAO().Delete(motivo); return(this.WriteSucess(result)); } catch (Exception ex) { return(this.WriteErrorInfo(ex?.Message)); } }
public MotivoN1 Delete(MotivoN1 t) { Dictionary <string, object> d = new Dictionary <string, object>() { { "ID", t.ID } }; using (DataTable dt = this.GetDataTable("spDeleteMotivoN1 @ID", d)) { this.CheckPatternError(dt.Rows); foreach (DataRow row in dt.Rows) { return(t); } } return(null); }
public ObservableCollection <MotivoN2> GetByMotivoN1(MotivoN1 motivo) { Dictionary <string, object> dic = new Dictionary <string, object>() { { "ID", motivo.ID } }; ObservableCollection <MotivoN2> list = new ObservableCollection <MotivoN2>(); using (DataTable dt = this.GetDataTable("spGetMotivosN2ByIDMotivoN1 @ID", dic)) { foreach (DataRow row in dt.Rows) { list.Add(this.ParseToDTO(row)); } } return(list); }
public MotivoN1 SaveUpdate(MotivoN1 t) { using (DataTable dt = this.GetDataTable("spSaveUpdateMotivosN1 @ID, @DESCRICAOMOTIVO, @DATARI", this.ParseToParameters(t))) { foreach (DataRow row in dt.Rows) { Int64 id = row.ParseToInt64("ID"); t.ID = id > 0 ? id : t.ID; foreach (MotivoN2 m in t?.MotivoN2) { new DAOFactory().InitMotivoN2DAO().SaveUpdate(m); } return(t); } } return(null); }
public IActionResult SaveUpdate([FromServices] DAOFactory dao, [FromBody] MotivoN1 motivo) { MotivoN1 result = dao.InitMotivoN1DAO().SaveUpdate(motivo); return(this.WriteSucess(result)); }