public int Delete([FromBody] UbicacionModel model) { if (!ModelState.IsValid) { throw new HttpRequestException(string.Format( this.myErrorHandler.GetMessage(MensajesErrorEnum.Validacion), ModelState.Values.First().Errors.First().ErrorMessage)); } var ubicacion = this.myService.GetById(model.Id); if (ubicacion == null) { throw new HttpRequestException(this.myErrorHandler.GetMessage(MensajesErrorEnum.ParametroNoExiste)); } var result = this.myService.Remove(model.Id); if (result.CompareTo(0) > 0) { return(result); } else { throw new HttpRequestException(this.myErrorHandler.GetMessage(MensajesErrorEnum.NoAutorizaBorrado)); } }
public UbicacionModel Create([FromBody] UbicacionModel model) { if (!ModelState.IsValid) { throw new HttpRequestException(string.Format( this.myErrorHandler.GetMessage(MensajesErrorEnum.Validacion), ModelState.Values.First().Errors.First().ErrorMessage)); } var ubicacion = new UbicacionModel { Descripcion = model.Descripcion, Direccion = model.Direccion }; var result = this.myService.Add(ubicacion); if (result.CompareTo(0) > 0) { return(this.myService.Where(p => p.Descripcion.Equals(model.Descripcion)).FirstOrDefault()); } else { throw new HttpRequestException(this.myErrorHandler.GetMessage(MensajesErrorEnum.NoAutorizaCreacion)); } }
public async Task <UbicacionModel> Edit([FromBody] UbicacionModel request) { if (!ModelState.IsValid) { throw new HttpRequestException(string.Format( this.myErrorHandler.GetMessage(MensajesErrorEnum.Validacion), ModelState.Values.First().Errors.First().ErrorMessage)); } var ubicacion = await this.myService.GetById(request.Id); if (ubicacion == null) { throw new HttpRequestException(this.myErrorHandler.GetMessage(MensajesErrorEnum.ParametroNoExiste)); } var result = await this.myService.Update(request); if (result.CompareTo(0) > 0) { return(await this.myService.GetById(request.Id)); } else { throw new HttpRequestException(this.myErrorHandler.GetMessage(MensajesErrorEnum.NoAutorizaActualizacion)); } }
// ***************************** ***************************** ***************************** // constructor public UbicacionAddViewModel(UbicacionViewModel UbicacionViewModel) { this._ParentUbicacion = UbicacionViewModel; this._UbicacionRepository = new GestorDocument.DAL.Repository.UbicacionRepository(); this._Ubicacion = new UbicacionModel() { IdUbicacion = new UNID().getNewUNID(), IsActive = true }; }
public async Task <ActionResult <UbicacionModel> > Post(UbicacionModel obj) { var name = await _IUBICACIONService.Add(obj); if (name == null) { return(NotFound()); } return(name); }
public static UBICACION Map(UbicacionModel dto) { return(new UBICACION() { PersonaID = dto.id, UbicacionLatitud = dto.latitud, UbicacionLongitud = dto.longitud, EmpresaID = dto.idemp, UbicacionObservaciones = dto.obs }); }
private void dataGrid_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { foreach (DataGridViewRow row in dataGrid.Rows) { UbicacionModel ubic = row.DataBoundItem as UbicacionModel; if (ubic.Disponible) { row.DefaultCellStyle.BackColor = Color.FromArgb(230, 255, 230); } else { row.DefaultCellStyle.BackColor = Color.FromArgb(255, 230, 230); } } }
public async Task <HttpResponseMessage> PostUbicacion(UbicacionModel Ubicacion) { try { if (Ubicacion != null) { _ubicacion = new Ubicacion(); _ubicacion.IdEmpresa = Ubicacion.IdEmpresa.Value; _ubicacion.Calle = Ubicacion.Calle; _ubicacion.NoExterior = Ubicacion.NoExterior; _ubicacion.NoInterior = Ubicacion.NoInterior; _ubicacion.CodPostal = Ubicacion.CodPostal.Value; _ubicacion.Colonia = Ubicacion.Colonia; _ubicacion.Localidad = Ubicacion.Localidad; _ubicacion.Municipio = Ubicacion.Municipio; _ubicacion.Estado = Ubicacion.Estado; _ubicacion.Pais = Ubicacion.Pais; _ubicacion.Telefono = Ubicacion.Telefono; _ubicacion.Gerente = Ubicacion.Gerente.Value; Ubicacion.Activo_Inactivo = true; _ubicacion.Activo_Inactivo = Ubicacion.Activo_Inactivo; db.Ubicacion.Add(_ubicacion); await db.SaveChangesAsync(); return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(ex.Message) }); } }
public bool CanSave() { bool _CanSave = false; if ( (!String.IsNullOrEmpty(this._Ubicacion.UbicacionName)) && (this._Ubicacion != null) ) { _CanSave = true; this._CheckSave = this._UbicacionRepository.GetUbicacionAdd(this._Ubicacion); if (this._CheckSave != null) { _CanSave = false; ElementExists = "El elemento ya existe."; } else { _CanSave = true; ElementExists = ""; } } return _CanSave; }
public async Task <UbicacionModel> Add(UbicacionModel obj) { var entity = await _IUBICACIONRepository.Add(UbicacionMapper.Map(obj)); return(UbicacionMapper.Map(entity)); }
public async Task <int> Update(UbicacionModel entrada) { return(await this.myService.Update(this.myMapper.Map <UbicacionModel, Ubicacion>(entrada))); }
public int Add(UbicacionModel entrada) { return(this.myService.Add(this.myMapper.Map <UbicacionModel, Ubicacion>(entrada))); }