public void AddTipoUbicacion(TipoUbicacion tipoUbicacion) { if (ExistsTipoUbicacion(tipoUbicacion.EmpresaId, tipoUbicacion.Codigo)) { throw new ApplicationException("Ya existe un tipo de ubicacion con el código indicado"); } _context.TiposUbicacion.Add(tipoUbicacion); _context.SaveChanges(); }
public void UpdateTipoUbicacion(TipoUbicacion tipoUbicacion) { if (ExistsTipoUbicacion(tipoUbicacion.EmpresaId, tipoUbicacion.Codigo, tipoUbicacion.TipoUbicacionId)) { throw new ApplicationException("Ya existe un tipo de ubicacion con el código indicado"); } _context.TiposUbicacion.Attach(tipoUbicacion); _context.Entry(tipoUbicacion).State = EntityState.Modified; _context.SaveChanges(); }