// ***************************** ***************************** ***************************** // constructor public EstPuntoMedAddViewModel() { this._EstPuntoMedRepository = new Protell.DAL.Repository.EstPuntoMedRepository(); this._PuntoMedicionRepository = new Protell.DAL.Repository.PuntoMedicionRepository(); this._EstructuraRepository = new Protell.DAL.Repository.EstructuraRepository(); this._EstPuntoMed = new EstPuntoMedModel() { IdEstPuntoMed = new UNID().getNewUNID(), IsActive = true }; this.LoadInfoGrid(); }
// ***************************** ***************************** ***************************** // constructor public EstPuntoMedModViewModel(EstPuntoMedModel p) { this._EstPuntoMedRepository = new Protell.DAL.Repository.EstPuntoMedRepository(); this._EstructuraRepository = new Protell.DAL.Repository.EstructuraRepository(); this._PuntoMedicionRepository = new Protell.DAL.Repository.PuntoMedicionRepository(); this._EstPuntoMed = new EstPuntoMedModel() { IdEstPuntoMed = p.IdEstPuntoMed, ESTRUCTURA = new EstructuraModel() { IdEstructura = p.IdEstructura, EstructuraName = p.ESTRUCTURA.EstructuraName }, PUNTOMEDICION = new PuntoMedicionModel() { IdPuntoMedicion = p.IdPuntoMedicion, PuntoMedicionName = p.PUNTOMEDICION.PuntoMedicionName }, IsActive = true }; this.LoadInfoGrid(); var i = 0; foreach (PuntoMedicionModel v in this.PuntoMedicions) { i++; if (v.IdPuntoMedicion == this.EstPuntoMed.PUNTOMEDICION.IdPuntoMedicion) { this.EstPuntoMed.PUNTOMEDICION = this.PuntoMedicions[i - 1]; break; } } var j = 0; foreach (EstructuraModel v in this.Estructuras) { j++; if (v.IdEstructura == this.EstPuntoMed.ESTRUCTURA.IdEstructura) { this.EstPuntoMed.ESTRUCTURA = this.Estructuras[j - 1]; break; } } }
public bool CanSave() { bool _CanSave = false; if ((this._EstPuntoMed != null)) { _CanSave = true; this._CheckSave = this._EstPuntoMedRepository.GetEstPuntoMedADD(this._EstPuntoMed); if (this._CheckSave != null) { _CanSave = false; ElementExists = "El elemento ya existe."; } else { _CanSave = true; ElementExists = ""; } } return _CanSave; }